← All topics
Quiz: Semaphores and Classic Problems: questions with answers
9 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. In the textbook implementation, a semaphore's value is −3. What does that mean?
- Q2. A semaphore starts at x. After 8 waits and 3 signals its value is 1. What is x?
- Q3. Two threads each run x = x + 1 once on shared x = 0, with no lock. Which final values are possible?
- Q4. In the bounded buffer, which semaphore makes the producer block when the buffer is full?
- Q5. Why must signal() check "value ≤ 0" rather than "value < 0" before waking a process?
- Q6. In the readers-first readers-writers solution, which reader performs wait(rw)?
- Q7. Which change makes the dining philosophers deadlock-free?
- Q8. What does this print? (code)
- Q9. What is the main problem with a busy-waiting (spinlock) wait()?