Questions tagged [pthreads]

For questions related to POSIX Threads API.

POSIX Threads, also known as pthreads is a set of application programming interfaces defined in the POSIX standards and intended for building portable multi-threaded applications. It is supported on many POSIX-conformant systems and often implemented as a library, typically called libpthread.

33 questions
42
votes
3 answers

How is a signal "delivered" in Linux?

I am confused by the terminology used to describe Linux signal delivery. Most texts say things like "the signal is delivered to the process" or "the signal is delivered to the thread". It is my understanding that a signal is "delivered" to a signal…
Albert
  • 511
  • 2
  • 4
11
votes
1 answer

Get PID from TID

I run iotop to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about…
Nathaniel M. Beaver
  • 1,246
  • 13
  • 28
6
votes
1 answer

Portable way to get all thread ids running inside a process.

During the porting of an application form Linux to FreeBSD I came up with the following problem. I need to get all thread id of all threads running inside my application. In terms of PThreads, I need an instance of an pthread_t array which contain…
M.K. aka Grisu
  • 191
  • 1
  • 5
4
votes
2 answers

unable to create new native Thread or Resource temporarily unavailable after 10K threads

I'm trying to allocate more than 10K threads on both a Fedora 30 (12GB of RAM) and Ubuntu 16 Linux machines (16GB of RAM). I get these errors around 10k threads: Java: unable to create new native Thread C: Resource temporarily unavailable Follows…
robob
  • 584
  • 1
  • 4
  • 12
3
votes
1 answer

Unlimited stack size with pthreads

My default stack size (according to ulimit -s) is 8192 kB, so naturally the code below segfaults when I try to run it. Also, naturally, it works fine if I do a 'ulimit -s 9000'. However, when I do a 'ulimit -s unlimited' the code segfaults again.…
user3856370
  • 237
  • 2
  • 8
3
votes
1 answer

Scheduling policy of a POSIX thread Vs kernel's Completely Fair Scheduler when the thread is actually executing

I have some doubts about setting the policy of a thread and how that policy is going to be followed while it is executing. Pthread allows setting the scheduling policy of a thread to SCHED_FIFO/SCHED_RR/SCHED_OTHER. I am trying to understand how…
Franc
  • 229
  • 3
  • 15
2
votes
2 answers

What is the region of memory allocated by malloc()?

I was writing a multi-threaded C program using pthread library. The program calls the malloc() from a thread and the main-thread. When I inspected the memory address returned by malloc(), the address returned by the malloc() in the main-thread was…
arka
  • 193
  • 5
2
votes
2 answers

How to comprehend Cpus_allowed and thread id number?

Environment: OS --debian + python3. All the output info below ommit unimportant. Get my computer's cpu info with cat /proc/cpuinfo : cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model name : Intel(R) Celeron(R) CPU…
showkey
  • 79
  • 23
  • 67
  • 128
2
votes
0 answers

Suddenly I see a lot of involuntary context switches for multi threaded app

I have a multi-threaded app, with 4 worker threads that until recently performed very well on my 4-core CPU. The system is running Ubuntu 16.04.3 LTS. Today I updated my OS with sudo apt-get dist-upgrade Now, I suddenly see much lower performance in…
Bram
  • 849
  • 9
  • 12
1
vote
1 answer

Is it possible to get the CPU time of any thread on Linux by calling clock_gettime?

If I know the TID of an arbitrary thread that is running on my system, I can easily compute its pthread cpu clock ID. But would I be able to call clock_gettime from my program and get its CPU time? My experiments suggest it's not possible, but I…
Phoenix87
  • 121
  • 5
1
vote
1 answer

What is the process state when pthread_mutex() is executed

Following are the Linux Process states; R: running or runnable, it is just waiting for the CPU to process it S: Interruptible sleep, waiting for an event to complete, such as input from the terminal D: Uninterruptible sleep, processes that cannot be…
Franc
  • 229
  • 3
  • 15
1
vote
1 answer

Why is No manual entry for pthread_mutex_lockerror prompted?

I want to check the use of the pthread_mutex_lock function, so I execute the command man pthread_mutex_lock, the result appears No manual entry for pthread_mutex_lock. I checked the information on the Internet and said that there was a No manual…
1
vote
1 answer

Installing Read/Write locks documentation on Debian

I'm trying to write a program that uses read/write locks and would like to install the man pages for this type of lock. I already have installed the packages manpages-dev man-db glibc-doc Could you please tell me the package that installs them or…
tigre200
  • 13
  • 2
1
vote
0 answers

Behavior of Linux kernel with respect to machine check exceptions (MCE) and threads

I was recently working with custom hardware that was not fully respecting the PCIe bus standards, and certain reads from the device would cause a bus fault and Linux machine check exception. When this happened, the pthread in my application that had…
Colin
  • 11
  • 1
1
vote
1 answer

file lock existence check on remote host

I want to check the existence of file lock on a file in gluster file system. So that I can see from any host that whether file lock is held by any process (remote or local) on file in gluster file system. For Example: I have two host: h1 and h2,…
dcds
  • 932
  • 4
  • 13
  • 23
1
2 3