Skip to content

Instantly share code, notes, and snippets.

@willprice
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willprice/c669340e34f4af1c8c9f to your computer and use it in GitHub Desktop.
Save willprice/c669340e34f4af1c8c9f to your computer and use it in GitHub Desktop.
// Each process runs this code.
wants_to_enter[id] = true;
// Be polite and let them enter
turn = other_process_id;
while (wants_to_enter[other_process_id] == true && turn == other_process_id) {
// let them enter critical section
}
critical_section();
wants_to_enter[id] = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment