Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. Windows Threading > Atomic Updates of Variables

Atomic Updates of Variables

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.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint