I’m learning the pthread_cancel function and testing whether thread would be cancelled when it doesn’t reach cancellation point. Thread is created by default attribute and make it running in add loop. But when cancellation request was sent and thread exit immediately. It doesn’t reach cancellation point and I think it should not respond to the request immediately. Answer To have
Tag: multithreading
Many-to-one mapping of user threads to a kernel thread
As I understand it, in many-to-one mapping, one kernel thread manages many user threads. This kernel thread helps the user threads make system calls etc. What I don’t understand is: Why do we have many-to-one mapping if a single blocking call would block all user threads managed by the kernel thread ? In many-to-one mapping of user threads to a
Linux – Get the start and end of the stack memory for a thread
I am trying to port something to Linux. My original code (for a RTOS) looks like: Later the stack and stackSize are used by the garbage collector and to get some thread statistics. Now, how do I convert the above code to Linux? Answer You should use Pthread: http://www.manpagez.com/man/3/pthread_attr/ http://www.manpagez.com/man/3/pthread_create/
Any equivalent function to pthread_getcpuclockid since i have tid of Thread
To get perf statistics of parallel running threads – To get list of threads I use thread list in /proc/self/task Now I want to get ID of a thread’s CPU time clock. But clock_getcpuclockid only works with PIDs. pthread_getcpuclockid requires the pthread id of thread and I did not find any way to get pthread id from TId of thread
linux: sigwait() takes precedence over pthread_sigmask(SIG_UNBLOCK)?
In a program, SIGCHLD is blocked from main thread, then thread “THREAD_1” is doing sigwait(), thread “THREAD_2” which forks a child process and kills it, in this thread I called pthread_sigmask(SIG_UNBLOCK, &set, 0) to unblock SIGCHLD before killing the child. But SIGCHLD is still being picked up by sigwait(). Other than unblock SIGCHLD from main() before creating threads, is there
Why is a multithreaded C program forced to a single CPU on Mac OS X when system() is used in a thread?
I encountered a strange difference in the behavior of a program using pthreads between Linux and Mac OS X. Consider the following program that can be compiled with “gcc -pthread -o threadtest threadtest.c”: Running the resulting executable on a 4-core Mac OS X machine results in the following behavior: Note that the number of actual cores is probably not even
Linux – make sure a core is exclusively saved for critical tasks
I have a process that is launched on a Linux-based machine with exactly two cores. Let’s assume my process is the only process in the system (I will ignore other processes and even the system’s ones). My process is divided to two parts: Critical performance code Low priority code Also let’s assume my main process was launched on Core 0,
C++ std::thread “Attempt to use a deleted function”
Here’s the relevant code and the relevant error, I’m not really sure what to make of it. That’s in thread.cpp, the next is in log.cpp… and Here’s the relevant error: Answer I think the problem is the declaration of the parameter func. It is declared as a void pointer instead of a pointer to a function returning void. Instead of,
Is iptables thread safe?
This seems to me to be a basic question, but google and SO fail to give me an answer. As the title says, is iptables thread safe? If I have multiple processes making calls to iptables, should I create a lock for myself? There seems to be some threads from 2009 querying if netfilter is thread-safe, with no solid resolution.
Kill python thread using os
I’ve already asked similar question many times, but still can’t find appropriate solution. I have and external function, that could run in some cases very long. I want to interrupt it after, say, 30 seconds. How do I do that? Threads are good, but I can’t stope them (i don’t have access to external function’s code) Multiprocessing is also not