The semaphore intrinsics provide means for atomically incrementing, decrementing, and exchanging data with a “semaphore,” a protected data object used for communication with other processes on Windows NT. In each case, the data associated with the semaphore is treated as volatile by the compiler. During optimization, volatile objects are not assumed to be constant; other processes can change their values between readings of the value of the volatile object.
Each of these operations is interlocked. No other process can interfere with the operation of the function until it completes and exits.