126
Using semaphores to synchronize
processes
n
We have 2 processes:
P1 and P2
n
Statement S1 in P1
needs to be performed
before statement S2 in
P2
n
Then define a
semaphore “synch”
n
Initialize synch to 0
n
Proper synchronization
is achieved by having in
P1:
S1;
signal(synch);
n
n
And having in P2:
wait(synch);
S2;