Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three
Answers
Answered by
2
P(S); process_arrived++; V(S); while (process_arrived !=3); P(S); process_left++; if (process_left==3) { process_arrived = 0; process_left = 0; } V(S);
}
The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally.
The above implementation of barrier is incorrect. Which one of the following is true?
The barrier implementation is wrong due to the use of binary semaphore SThe barrier implementation may lead to a deadlock if two barrier in invocations are used in immediate succession.Lines 6 to 10 need not be inside a critical sectionThe barrier implementation is correct if there are only two processes instead of three.
}
The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally.
The above implementation of barrier is incorrect. Which one of the following is true?
The barrier implementation is wrong due to the use of binary semaphore SThe barrier implementation may lead to a deadlock if two barrier in invocations are used in immediate succession.Lines 6 to 10 need not be inside a critical sectionThe barrier implementation is correct if there are only two processes instead of three.
timelsss:
master
Similar questions