|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wait(S):
|
|
S.count--;
|
|
if (S.count<0) {
|
|
block this process
|
|
place this process in S.queue
|
}
|
|
|
|
|
|
|
|
|
|
|
signal(S):
|
|
S.count++;
|
|
if (S.count<=0) {
|
|
remove a process P from S.queue
|
|
place this process P on ready list
|
}
|
|
|
|
|
|
|
S.count
may be initialized to a
|
nonnegative
value (often = 1)
|
|
|
|
|
|
|
|
|
|
|