CS 481: Operating System Principles Assignment # 4: Due Date = Friday, 10/02/98 Consider the following procedures (intended to guarantee mutual exclusion) to be run before and after a process attempts to enter and leave the critical section respectively. Assume that only two processes, P0 and P1, ever wish to enter the critical section. int turn=0; int flag[2]; flag[0]=0; flag[1]=0; Enter_critical_section(int this_process) { flag[this_process] = 1; if (turn != this_process) { turn = this_process; while (flag[ 1 - this_process] == 1); } } Leave_critical_section(int this_process) { turn = 1 - this_process; flag[this_process] = 0; } (i) Is mutual exclusion guaranteed? If so, present an informal but convincing proof. If not, enumerate a sequence of events leading to both proceses in the critical section. (ii) Is it possible that a process waits indefinitely while the other enters and exits the critical section at will? If so, enumerate a sequence of events leading to this possibility. If no, present an informal but convincing proof. (iii) Is it possible that both processes are waiting indefinitely, attempting to enter the critical section, with neither making progress toward this goal? If so, enumerate a sequence of events leading to this possibility. If no, present an informal but convincing proof. Kindly have all answers printed out.