Signal
type semaphore = record
value: integer:
L: list of processes;
end
wait(S):
S.value = S.value - 1;
if S.value < 0
then begin
add this process to S.L;
block;
end;
signal(S):
S.value = S.value + 1;
if S.value <= 0
then begin
remove a process P from S.L;
wakeup P
end;
Signal and Wait must be
atomic
Previous slide
Next slide
Back to first slide
View graphic version