Skills101
← All practice quizzes

Quiz: Semaphores and Classic Problems

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

How a semaphore really works inside, the semaphore-value questions asked in GATE, a working producer-consumer program, the possible results of an unprotected counter, Peterson's solution, and correct solutions to readers-writers and dining philosophers.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    A counting semaphore starts at 10. Then 6 wait and 4 signal operations are performed. What is its final value?

  2. Question 2

    In the textbook implementation, a semaphore's value is −3. What does that mean?

  3. Question 3

    A semaphore starts at x. After 8 waits and 3 signals its value is 1. What is x?

  4. Question 4

    Two threads each run x = x + 1 once on shared x = 0, with no lock. Which final values are possible?

  5. Question 5

    In the bounded buffer, which semaphore makes the producer block when the buffer is full?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →