Chapter 6: Process Synchronization - Csl Mtu
Chapter 6: Process Synchronization - Csl Mtu
Chapter 6: Process Synchronization - Csl Mtu
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Algorithm II: 1/2<br />
bool flag[2];<br />
I am interested<br />
do {<br />
wait for you<br />
}<br />
flag[i] = TRUE;<br />
while (flag[j]);<br />
critical section<br />
flag[i] = FALSE;<br />
I am not interested<br />
enter<br />
exit<br />
Variable flag[i]<br />
is the “state” of<br />
process P i :<br />
interested or notinterested.<br />
P i expresses its<br />
intention to enter,<br />
waits for P j to exit,<br />
enters its section,<br />
and finally changes<br />
to “I am out” upon<br />
exit.<br />
17