Week 30

Semaphores

Semaphores is a low level mechanism used for synchronizing tasks. Semaphores are essentially integer variable, but will always hold negative integers. There are two types of semaphores.

First, counting semaphores, help tasks to be acquired or released numerous times. If the initial count = 0, the counting semaphore should be created in the unavailable state or if count > 0, then it would be created in a available state. The other type of semaphore is a binary semaphore. A binary semaphore is restricted to 0 or 1, this basically means that the wait operation only works if semaphore = 1 or the signal operation will only work when semaphore = 0.

Wait operations will decrement a semaphore where as signal or post will increment a semaphore.