SEMAPH (located in \TOOLKIT\SAMPLES\OS2\SEMAPH) demonstrates the use of mutex and event semaphores. In the sample, several threads share access to the same resource.
A mutex semaphore is used to guarantee that only one thread has access to the resource at a time. A mutex semaphore is used to check for a stop event or for a user signal to give up the resource.
An event semaphore is used to signal the thread to give up the resource. An event semaphore can be posted by the user, or run in auto mode, in which case the event semaphore will be posted at fixed time intervals.
Each thread can be displayed as a square of a unique color. Similarly, the resource can be displayed as a rectangle; its color is that of the first thread that owns it.