Semaphore Implementation
Semaphore is a record:
type semaphore = record
value: integer;
L : list of process;
end;
Assumes two operations:
block suspends the process that invokes it.
Wakeup(p) resumes the execution of a blocked process p.
Atomic operations:
Wait(s):
S.value := S.value -1;
if S.value < 0
add this process to S.L;
block;
end;
Signal(s):
S.value := S.value + 1;
if S.value ? 0
remove a process P from S.L;
wakeup(P);
end;
Previous slide
Next slide
Back to first slide
View graphic version