MCQs City stays free thanks to ads. Please turn off your ad blocker for this site so content and features keep working.
Operating System
Semaphores 2
Q
The program follows to use a shared binary semaphore T. Process A int Y; A1: Y = X*2; A2: X = Y; signal(T); Process B int Z; B1: wait(T); B2: Z = X+1; X = Z; T is set to 0 before either process begins execution and, as before, X is set to 5. Now, how many different values of X are possible after both processes finish executing?
AA. One
BB. Two
CC. Three
DD. Four
Correct Answer:
A. A. One
Explanation:
The semaphore T ensures that all the statements from A finish execution before B begins. So now there is only one way in which statements from A and B can be interleaved:
A1 A2 B1 B2: X = 11.