Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save TommyWu-fdgkhdkgh/b422e19742db9cc8c30c45de8c8f3a36 to your computer and use it in GitHub Desktop.

Select an option

Save TommyWu-fdgkhdkgh/b422e19742db9cc8c30c45de8c8f3a36 to your computer and use it in GitHub Desktop.
do{
/* entry section */
wait(chopstick[i]);
wait(chopstick[(i+1) % 5]);
/* eat for a while */
/*critical section*/
/* exit section */
signal(chopstick[i]);
signal(chopstick[(i+1) % 5]);
/* think for awhile */
/* remainder section */
}while(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment