Which is more efficient, basic mutex lock or atomic integer?

Atomic operations leverage processor support (compare and swap instructions) and don’t use locks at all, whereas locks are more OS-dependent and perform differently on, for example, Win and Linux. Locks actually suspend thread execution, freeing up cpu resources for other tasks, but incurring in obvious context-switching overhead when stopping/restarting the thread. On the contrary, threads … Read more

How to set up pthreads on windows?

The .dll can go in any directory listed in your PATH environment variable. The .lib file can go in any directory listed in your LIB environment variable. The .h files can go in any directory listed in your INCLUDE environment variable. Also see the FAQs page of the link you shared . Read Q6, Q7, … Read more

Which thread handles the signal?

If you send a signal to a process, which thread in the process will handle this signal is undetermined. According to pthread(7): POSIX.1 also requires that threads share a range of other attributes (i.e., these attributes are process-wide rather than per-thread): … – signal dispositions … POSIX.1 distinguishes the notions of signals that are directed … Read more

Linux/POSIX equivalent for Win32’s CreateEvent, SetEvent, WaitForSingleObject

The POSIX equivalent for what you described is POSIX condition variables. Note that condition variable must always be used in pair with a POSIX mutex, but quite frequently several condition variables use the same mutex, so if you aren’t going to use the mutex exclusively for the condition variable, you shouldn’t place it in the … Read more