semaphores, classic problems
semaphores, classic problems
semaphores, classic problems
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Bakery algorithm<br />
bool choosing[n]; // initially false<br />
int number[n]; // initially 0<br />
cobegin<br />
/* process i */<br />
while(true) {<br />
choosing[i] = true;<br />
number[i] = max(number[0], ..., number[n]) + 1;<br />
choosing[i] = false;<br />
for(j = 0; j != i; j++) {<br />
while(choosing[j]); // busy wait<br />
while(number[j] && number[j]