Signalling and Resource Counting Using Semaphores

Learn how semaphores can be used for signaling and resource counting.

Semaphores

The word semaphore means something that can be used for signaling, such as a flag or a light. In the example that follows, we will see how we can use semaphores for signaling different states that other threads can be waiting for.

A semaphore can also be used to control access to a resource, similarly to how a std::mutex restricts access to a critical section:

Get hands-on with 1200+ tech skills courses.