Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The Windows API provides a large number of atomic operations, which are referred to in Windows terminology as interlocked functions. For the full list of functions, refer to the Windows documentation. An example of one such function is InterlockedExchangeAdd(), which atomically adds a value to a variable of type LONG (in Windows a long variable is 32 bits in size, and a LONGLONG is 64 bits in size; the size does not change depending on whether the application is 32-bit or 64-bit). Listing 6.36 shows an example of using InterlockedExchangeAdd() to atomically increment a variable by ten.