Consider the mutex algorithm of Ricart and Agrawala. Recall the assumptions: 1.
ID: 3813291 • Letter: C
Question
Consider the mutex algorithm of Ricart and Agrawala. Recall the assumptions:
1. Each thread executes at non-zero speed.
2. Communication lines and input ports are non-FIFO (“non” here means “not necessarily”).
3. Each thread can receive its input messages independently, without synchronization issues with other threads’ inputs.
In each question, a modification to the code is suggested.
Will the new code work? (YES or No).
If Yes, give an explanation, in less than 50 words.
If No, give a counter example. In this example, assume we have EXACTLY TWO processes P0 and P1 in the system.
Q:
In the first thread, the statement “Requesting_critical_section := TRUE;” is moved up, to the point immediately before P(shared_vars).
Explanation / Answer
import java.io.*;
class FIFO
the amount of inputs :”);
n=Integer.parseInt(br.readLine());
int inp[]=new int[n];
System.out.println(“Enter the inputs:”);
for(int i=0;i<n;i++)
inp[i]=Integer.parseInt(br.readLine());
System.out.println(“—————“);
for(int i=0;i<3;i++)
fifo[i]=-1;
int Hit=0;
int Fault=0;
int j=0;
boolean check;
for(int i=0;i<n;i++)
if(check==false)
}
System.out.println(“HIT:”+Hit+” FAULT;”+Fault);
}
}