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 III: a Combination 1/4<br />
// process P i<br />
bool flag[2];<br />
int turn;<br />
I am interested<br />
do {<br />
yield to you first<br />
I am done<br />
flag[i] = TRUE;<br />
turn = j;<br />
while (flag[j] && turn == j);<br />
critical section<br />
flag[i] = FALSE;<br />
exit<br />
enter<br />
wait while you are<br />
interested and it is<br />
your turn.<br />
}<br />
19