4.1.1 About Synchronization Objects

A synchronization object is a data structure whose current state—either Signalled or Not-Signalled—can be used to coordinate the execution of two or more threads. A thread can interact with one of these objects either by modifying its state or by waiting for it to be in a Signalled state. When a thread waits for an object, the execution of the thread is blocked as long as the state of the object is Not-Signalled. Typically, a thread will wait for a synchronization object before using a shared resource or performing an operation that must be coordinated with other threads.

There are four types of synchronization objects: Mutex (mutual exclusion) objects, Semaphore objects, Event objects, and Critical Section objects. The features of each type enable a different functionality. A Mutex object is used to prevent simultaneous use of a shared resource, such as a file, shared memory, or a peripheral device. A Semaphore object is used as a resource gate that limits the use of a resource by counting threads as they pass in and out of the gate. An Event object is used to notify a waiting thread that an event has occurred. A Critical Section object is similar to a Mutex except that it can only be used by the threads of a single process.