7.2. Four Different Synchronization Methods

The 32-bit APIs provides four different synchronization mechanisms:

  1. Critical sections

  2. Mutexes

  3. Semaphores

  4. Events

All four mechanisms may be used to solve the two problems described above, although once you understand them you will see that either critical sections or mutexes would be the logical choices for these particular problems. Semaphores and events have more advanced applications. The following four sections look at each of the techniques and show you how they can be used to solve the simple counting problem demonstrated in Listing 7.1, as well as other more important problems.

One thing that you will notice in the following examples is that all of the synchronization mechanisms implementefficient ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.