🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Semaphores and Classic Problems: all 9 questions

Quiz: Semaphores and Classic Problems · Question 5 of 9

Why must signal() check "value ≤ 0" rather than "value < 0" before waking a process?

Why must signal() check "value ≤ 0" rather than "value < 0" before waking a process?

  1. A.It is a matter of style only
  2. B.After adding 1, a value of 0 means one process was still waiting before the signal
  3. C.Values can never be negative
  4. D.So that it wakes every process
Answer & explanation

Correct answer: After adding 1, a value of 0 means one process was still waiting before the signal

A value of −1 before the signal (one waiter) becomes 0 after it, and that waiter must be woken.

Can you get the rest right without peeking?

Take the timed Quiz: Semaphores and Classic Problems quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →