Semaphore is an interface to generally describe synchronization mechanism. This means it can have different implementations.
It Provides A way to block a no. of processes (sleep), A way to unblock / wakeup > 1 or more sleeping process.
S is a semaphore.
We have 2 functions which interact with it.
- Conditional if S <= 0, blocks (go to sleep), until it is more than 0 than we release.
- Decrement S
Signal(S) / Up(S) / v(S)
- Increments S
- Wakes up 1 sleeping process if any
- This operation never blocks
Reminder: The above specifies the behaviour, not the implementation.