Question: Consider the following codes of two processes sharing a variable turn that is initialized to 1. Do the processes satisfy all requirements of critical region

 Consider the following codes of two processes sharing a variable turn

Consider the following codes of two processes sharing a variable turn that is initialized to 1. Do the processes satisfy all requirements of critical region solution (i.e., mutual exclusion, progress & bounded waiting)? Explain. Process P0 /* other code */ while (turn i = 0) { } /* wait update (); /* critical region turn = 0; /* other code */ Process P1 /* other code */ while (turn i = 1) { } /* wait update (); /* critical region turn = 1; /* other code */ Suppose there are two processes -i and j, sharing variables turn and flag [2]. Consider the following code for process i. Process j has similar code. do { flag [i] = true; while (flag [j]) { if (turn == j) { flag [i] = false; while (turn == j); /* do nothing */ flag [i] = true; } } critical_task(); /* critical region */ turn = j; flag[i] = false; other_tasks (); /* remainder section */ } while (true); Explain whether the above solution satisfy the necessary conditions (mutual exclusion, progress & bounded waiting) of critical region

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!