Provide relevant parts of C-like codes for processess A,B,C,D and E in the follo
ID: 3793775 • Letter: P
Question
Provide relevant parts of C-like codes for processess A,B,C,D and E in the following synchronization problem.
Provide relevant parts of C-like codes for processes A, B, C, D and E in the following synchronization problem. Each process has a special (synchronization) point in its code, and each process may cross its synchronization point only if all other processes have reached or crossed their synchronization points. Provide relevant parts of C-like codes for processes X, Y, Z, W, V and S in the following synchronization problem. Each process has a special (synchronization) point in its code, and each process may cross its synchronization point only if at least two other processes reached or crossed their synchronization points. Assume that each process will cross its synchronization point only once.Explanation / Answer
1)Providing releavant parts of the C- like codes for Process A,B,C,D and E:
Here Each and Every Process has a synchorinization point;
struct process{
char synpoint;
}A,B,C,D,E;
struct process p[10]={A,B,C,D,E};
//code for process A:
int count = 0;
for(int i=0;i<5;i++){
if(!(strcmp(p[i].synpoint,"crossed"))
count++;
}
if(count>=2)
strcpy(p[0].synpoint ,"crossed");
2)Providing releavant parts of the C- like codes for Process X,Y,Z,W,Vand S:
Here Each and Every Process has a synchorinization point;
struct process{
char synpoint;
}X,Y,Z,W,V,S;
struct process p[10]={X,Y,Z,W,V,S};
//code for process X:
int count = 0;
for(int i=0;i<6;i++){
if(!(strcmp(p[i].synpoint,"crossed"))
count++;
}
if(count>=2)
strcpy(p[0].synpoint ,"crossed");
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.