| |
Semaphore Types
- Binary or counting
- Binary: Semaphore value can be T or F only
- Binary semaphores provide mutual exclusion
- Sometimes known as mutex locks
- Counting semaphores
- Can be used when the given resource has finite number of instances (n).
- Initialize semaphore.value to n.
Synchronization Among Processes
- Two Processes P1 and P2.
- How do we make sure that P1 executes S1 first before P2 executes S2?
| semaphore synch; |
|
P1:
S1;
synch.signal();
|
P2:
synch.wait();
S2 |
|