A file is to be shared among different processes, each

A file is to be shared among different processes, each of which has a unique number. The file can be accessed simultaneously by several processes, subject to the following constraint: The sum of all unique
do {
while (TRUE) {
flag[i] = want_in;
j = turn;
while (j != i) {
if (flag [j] I= idle) {
j = turn;
else
j = (j + 1) % n;
}
flag [i]
j = 0;
in_cs;
while ( (j < n) && (j = = i || flag[j] != in_cs))
j++;
if ( (j >= n) && (turn = = || flag [turn] idle)) break;
}
//critical section
j = (turn + 1) % n;
while (flag[j] == idle)
j = (j + 1) % n;
turn= j;
flag [i] = idle;
// remainder section
} while (TRUE);
Figure 6.26 The structure of process Pi in Eisenberg and McGuire's algorithm.
numbers associated with all the processes currently accessing the file must be less than n. Write a monitor to coordinate access to the file.






3079