Multiple choice

Consider following code

wait (s) : while not (s > 0) do keep testing s : s - 1 Signal(s) : s = s + 1 if value of s is - 2. And a process P executes first instruction, then which of the following is true?

  1. P will be granted to enter critical state

  2. P will not be able to enter critical state and terminate

  3. P will execute first instruction and terminate

  4. P will keep testing until variable s becomes greater than zero

  5. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Here as we know, semaphore variable has value 1 and 0 so if s gets 1 then P has permitted it to enter into critical region.