Skip to main content

Questions tagged [pthreads]

For questions related to POSIX Threads API.

Filter by
Sorted by
Tagged with
0 votes
2 answers
28 views

How to send a signal to a set of pthread within one process in Linux?

I am working on an embedded Linux system (kernel-5.10.24). There is a multi-threaded process needed to handle a certain of exception delivered through a signal. The process is something like below. ...
1 vote
0 answers
36 views

mysqld thread count exceeds max_connections

As the question title suggests: I have set max_connections = 2 in my my.cnf file, but when I activate my mysql daemon, the thread count sits at 37. I am searching online but cannot find indication my ...
0 votes
1 answer
2k views

How can I view threads for a running process that is creating threads?

I made a very small program that creates two threads: #include <pthread.h> #include <stdio.h> #include <unistd.h> void *start() { printf("Am a new thread!\n"); ...
0 votes
0 answers
97 views

Can I prevent a pthread from ever being interrupted by the scheduler?

I'm programming an embedded real-time Linux device with a 4 core ARM CPU. There is a requirement for a periodic computation at 10 kHz that should not jitter too much and should never be lost. My POSIX ...
0 votes
1 answer
57 views

Is there a way to prevent a descendant thread from getting into cgroup of its ancestor thread automatically?

I write some threads of my app to a Linux cpu cgroup, created by me, explicitly (let us talk e.g. about v1 for now, but if you know a way for v2, that would be also great). However, I see that ...
3 votes
2 answers
298 views

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 ...
6 votes
1 answer
3k views

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 ...
0 votes
1 answer
446 views

How many times has my process been preempted?

I wrote a simple program with a thread which runs on a CPU core. It spins kind of aggressively, and it takes 100% of the CPU core. I can see that with top + 1. After N minutes, I would like to be able ...
44 votes
3 answers
7k views

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&...
0 votes
2 answers
483 views

Simple Scan crashes almost immediately upon start-up

I'm using simple-scan on Debian and it is now always crashing. It worked fine a few months ago. I suspect that something got upgraded (I'm running bullseye) and broke things. The output from simple-...
0 votes
1 answer
616 views

Linker cannot find libpthread

I am trying to build 32bit versions of two programs, and both shows the same error message /usr/bin/ld: cannot find /media/34GB/Arquivos-de-Programas-Linux/Glibc-2.17-32bit/lib/libpthread.so.0 I ...
1 vote
1 answer
8k views

Custom priority value: is a pthread high sched prio positive or negative?

I’m trying to reimplement in a backward-compatible way the RobotC API from C (although some details would better fit or would be easier with C++), and trying to reimplement their multithreading API in ...
0 votes
2 answers
367 views

Xlib: what is the best implementation of GUI digital clock?

I am making an X application which contains a digital clock. The clock displays the current time in the format of "hh:mm". I want to master Xlib, so I want to use only Xlib (no other ...
-1 votes
1 answer
56 views

What security controls exist such that user processes can't assign themselves highest priority?

I'm learning about the Linux process scheduler and have been reading through the pthread_setsched function: https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html One thing that had ...
1 vote
1 answer
936 views

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 ...
1 vote
1 answer
1k views

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:...
3 votes
1 answer
1k views

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 '...
1 vote
1 answer
342 views

OpenBSD threads priorities

Can anybody explain how to work with thread priorities in OpenBSD? Information about this question in MAN pages is poor, it does not give clear understanding. In particular: sched_get_priority_min/...
0 votes
1 answer
472 views

Schedule jobs from a queue onto multiple threads

I have a function that has to process all files in a set of directories (anything between 5-300 files). The number of parallel threads to be used is user-specified (usually 4). The idea is to start ...
3 votes
1 answer
1k views

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/...
1 vote
1 answer
1k views

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 ...
1 vote
1 answer
103 views

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 ...
0 votes
1 answer
532 views

Problems with pthread scheduling and output

I am having some problems with outputing my threads in a right order. My program needs to take at least 2 parameters (could be more, but always 2 at a time because one is integer(how many second does ...
0 votes
1 answer
359 views

Do all threads originating from the same process sleep on wait_event_interruptible()?

If I have 3 pthreads: A, B, C, all originating from the same process, running in user space and one thread, thread B does a blocking read from a kernel module and is put to sleep, will threads A and C ...
1 vote
0 answers
115 views

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 ...
-1 votes
1 answer
4k views

fatal error : linux/interrupt.h : no such file or directory

I am developing code for interrupt. When I am including #include <linux/interrupt.h>, I get fatal error : linux/interrupt.h no such file or directory Why am I getting this error and how can I ...
4 votes
2 answers
2k views

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 ...
0 votes
0 answers
892 views

Can a signal in one thread, interrupt sleep period of another thread of the same process in linux

There are two threads (parent thread and child thread, both runs in their own infinite loop) in a process. The parent thread does only one work, i.e. to continuously (while(1)) check the system time ...
1 vote
1 answer
219 views

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 ...
2 votes
2 answers
1k views

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 ...
0 votes
1 answer
2k views

Is it recommended to use param.sched_priority in Linux FIFO during thread creation?

In my embedded device I absorb strange behaviour with the protocol we use, sometimes it takes a while to send the data via serial device using FIFO. My suspicion is Linux is not real-time OS and why ...
1 vote
0 answers
125 views

Linux (kernel 3.x and 4.x) Pthread and general process scheduling algorithms

I was wondering if both scheduling (contention) scopes (SYSTEM and PROCESS) are used in the Linux kernel scheduling logic. POSIX supports PROCESS scope pthreads (MXN model) and SYSTEM scope pthreads (...
12 votes
1 answer
9k views

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 ...
0 votes
2 answers
180 views

Thread Creation

Why do we use pthread_exit(NULL) method in main() method when creating threads? #include <stdio.h> #include <unistd.h> #include <pthread.h> void *message(void *arg){ char *...
2 votes
0 answers
851 views

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-...