Consider two processes P1 and P2 executing concurrently and sharing a semaphore S, which is initialized to 0. The semaphore operations in the processes appear as shown below:
Process P1 Process P2
- -
- -
S1 S2
wait(S) signal(S)
- -
- -
a) Which one of the following is true? (4 marks)
- (i) S1 and S2 will execute in any order
- (ii) S1 will always execute before S2
- (iii) S1 will always execute after S2
- (iv) P1 and P2 will be deadlocked
b) Explain your answer with reasoning. (4 marks)
c) What would happen if S was initialized to 1 instead of 0? (4 marks)