Programming with Hyper-Threading Technology: How to Write Multithreaded Software for Intel IA-32 Processors

Thread activities frequently have to be coordinated.
The simplest and fastest way of coordinating two threads is with a spin wait loop. However, this is a terribly wasteful solution and less expensive options exist.
The most common option is the mutex, which marks a section of code as being accessible by only one thread at a time.
Mutexes are kernel events on Windows and are thus not terribly efficient. Windows programs should therefore use critical sections, which are lightweight and fast implementations of the mutex concept.
If a Windows application needs only to perform mutual exclusion on a single numeric variable, it can use an even faster mechanism, the interlocked functions.
Finally, Windows uses events to schedule activities of multiple threads.
Pthreads uses other mechanisms to synchronize threads. Mutexes work the same way, although they are more efficient on Linux systems than their counterparts on Windows.
POSIX uses semaphores to signal threads one at a time to proceed, and condition variables to signal multiple threads.