




















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















































/* Variables are global and shared / for (; ;) { // process 1 - an infinite loop to show it enters // CS more than once. Turn is initially 1. p1wants = 1; while (p2wants == 1) { if (turn == 2) { p1wants = 0; while (turn == 2) {/ Empty loop */} p1wants = 1; } } critical_section(); turn = 2; p1wants = 0; noncritical_section(); }
/* Variables are global and shared / for (; ;) { // process 2 - an infinite loop to show it enters // CS more than once. p2wants = 1; turn = 1; while (p1wants && turn == 1) {/ empty loop */} critical_section(); p2wants = 0; noncritical_section(); }