Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. A solution to critical region problem for n processes is suggested as follows

ID: 3682758 • Letter: 2

Question

2. A solution to critical region problem for n processes is suggested as follows:

All elements of flag are initially idle. The initial value of turn is something between 0 and n -1 (it is immaterial).

The general structure of process Pi is:

do {

flag[i] = true;

while (flag[j]) {

if (turn == j) {

flag[i] = false;

while (turn == j); /* do nothing */

flag[i] = true; } }

/* critical section */

turn = j;

flag[i] = false;

/* remainder section */

} while (true);

Explain whether the above solution satisfy the necessary conditions (mutual exclusion, progress & bounded waiting) of critical region problem.

Explanation / Answer

Yes it satisifes the necessary confition.

the flag here will always be raised under critical section not depending on the loop count and also the flag can be used to enter into the critical section directly. Also if the other process has raised flag it will wait for turn.