© Thomas Kunz 2000
SCE 574
214
Semaphores: Observations
äWhen S.count >=0:  the number of processes that can execute wait(S) without being blocked = S.count
äWhen S.count<0: the number of processes waiting on S is = |S.count|
äAtomicity and mutual exclusion: no 2 processes can be in wait(S) and signal(S) (on the same S) at the same time (even with multiple CPUs)
äThis is a critical section problem: critical sections are blocks of code defining wait(S) and signal(S)
äHence: the critical sections here are very short: typically 10 instructions
äSolutions:
äuniprocessor: disable interrupts during these operations (ie: for a very short period). This does not work on a multiprocessor machine.
ämultiprocessor: use previous software or hardware schemes. The amount of busy waiting should be small.