Determine the correctness of the algorithm if it is


1. Check the conditions for concurrent processing (mutual exclusion, deadlock avoidance, and starvation avoidance) for the following modifications of Petersen's algorithm; if any condition if violated, show the steps leading to this violation:

A.
Pi()
while (true)
wantsIn[i) = true;
turn = i; // instead of j
while (wantsIn[j) && turn == j ) ;
critical section;
wantsIn[i) = false;

B.
Pi()
while (true)
wantsIn[i] = true;
turn = i;  // instead of j
while (wantsIn[j] && turn = = i;   // instead of j

critical section;

wantsIn[i] = false; i);

2. Determine the correctness of the following algorithm; if it is incorrect, show an example in which one of conditions for the critical-section problem is violated. Two processes Po and PI share the following variables:

Two processes Po and PI share the following variables:
boolean wantsIn[2] = {false, false};
int turn;
here is the code for process Pi, i = 0 or 1, and j = 0 or 1 (i.e., j = 1 - i).
Pi ( )
while (true)
wantsIn(i] = true;
while (turn == j)
while (wantsIn[j]);
turn = i;
critical section;
wantsIn[i] = false;

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Determine the correctness of the algorithm if it is
Reference No:- TGS02636273

Expected delivery within 24 Hours