Semaphore Properties
Atomic wait/signal and semaphore correctness
Open direct question →Most semaphore questions in GATE reduce to five recurring ideas: tracking semaphore values, protecting shared data, enforcing order, spotting deadlock, and handling Producer-Consumer synchronization.
One question asks for a semaphore value. Another asks which output can occur. Another hides a deadlock inside the order of two waits. The surface changes, but the same small set of reasoning structures keeps returning.
The goal is simple: recognize the pattern before you start simulating processes.
This guide covers 27 semaphore-focused GATE CSE PYQs. Additional questions from GATE IT, ISRO, UGC NET, TIFR, IIITH PGEE, BARC and GO Classes DPPs are included for extra practice across the same five patterns.
Extra Similar Practice questions reinforce a pattern already covered in the GATE CSE set.
Find the strongest clue in the question and jump directly to the reasoning pattern you should try first.
What is the semaphore value, and who must wait?
Look for an initial semaphore value followed by P(), V(), wait(), signal(), or a sequence of operations that changes the available permits.
Do permit accounting first. Track how many successful waits can occur before blocking becomes unavoidable.
| GATE CSE PYQ | What it tests |
|---|---|
| GATE CSE 1992 Q2(x) | Final counting-semaphore value after P/V operations |
| GATE CSE 1998 Q1.31 | Counting-semaphore arithmetic |
| GATE CSE 2016 Set 2 Q49 | Largest initial value that still leaves a P operation blocked |
Twenty P(S) operations create demand and twelve V(S) operations restore permits. The net excess demand is eight. Therefore, the largest initial value that still guarantees at least one blocked P(S) is seven. The key is recognizing permit accounting before thinking about scheduler interleavings.
Check the semaphore convention used in the question. In some definitions, a negative semaphore value represents the number of waiting processes.
Does the semaphore actually protect the shared state correctly?
Look for shared variables, binary versus counting semaphores, atomicity, starvation, busy waiting, Readers-Writers, or a proposed semaphore implementation.
Ask how many processes may enter, whether the protected update is atomic, and whether the solution guarantees progress as well as mutual exclusion.
| GATE CSE PYQ | What it tests |
|---|---|
| GATE CSE 1997 Q6.8 | Broken P/V usage and maximum processes in the critical section |
| GATE CSE 2013 Q34 | Counting semaphore allows concurrent non-atomic updates |
| GATE CSE 2021 Set 1 Q46 | Multiple waits, limited permits and race behavior |
| GATE CSE 2023 Q28 | Binary versus counting semaphore around shared updates |
| GATE CSE 1987 Q8a | Readers-Writers protocol using semaphores |
| GATE CSE 2000 Q20 | Readers-Writers, busy waiting and starvation |
| GATE CSE 2008 Q63 | Implement a counting semaphore using binary semaphores |
| GATE CSE 1990 Q1-vii | Why semaphore operations must be atomic |
| GATE CSE 2006 Q61 | Implement semaphore operations using an atomic primitive |
A binary semaphore initialized to one admits one thread at a time. A counting semaphore initialized above one can admit multiple threads together. If the shared read-modify-write operation is not atomic, those admitted threads can still race. The presence of a semaphore does not automatically mean mutual exclusion.
Mutual exclusion, deadlock freedom, starvation freedom and bounded waiting are different properties. Proving one does not automatically prove the others.
What must happen before what?
Look for required output sequences, possible execution orders, semaphore initializations, or a conversion between process code and a precedence graph.
Draw the dependency graph first. Read signal as 'unlocks' and wait as 'cannot pass until'.
| GATE CSE PYQ | What it tests |
|---|---|
| GATE CSE 1993 Q22 | Convert precedence constraints into semaphore synchronization |
| GATE CSE 1995 Q19 | Convert P/V synchronization into a precedence graph |
| GATE CSE 2003 Q80 | Force a repeating output sequence |
| GATE CSE 2003 Q81 | Restrict possible output patterns |
| GATE CSE 2010 Q45 | Possible executions and printed outputs |
| GATE CSE 2013 Q39 | Enforce a producer-before-consumer style dependency |
| GATE CSE 2022 Q9 | Initialize semaphores to enforce BCABC... |
| GATE CSE 2026 Set 2 Q41 | Possible output patterns with two binary semaphores |
For a repeating BCABC... sequence, identify the required dependencies: B before C, C before A, and A before the next B. Then choose the initial semaphore values that allow only the first required event to begin.
Do not enumerate every scheduler interleaving before extracting the forced order. Most ordering questions become much simpler as a partial-order graph.
Can a process block while holding something another process needs?
Look for multiple semaphores, nested waits, different acquisition orders, or a process waiting while still holding a semaphore.
At every wait, write what the process is already holding and identify which process can perform the signal needed to release it.
| GATE CSE PYQ | What it tests |
|---|---|
| GATE CSE 2000 Q1.21 | Circular wait among binary semaphores |
| GATE CSE 2004 Q48 | Semaphore acquisition order and deadlock |
| GATE CSE 2013 Q16 | Ordering multiple semaphore acquisitions |
| GATE CSE 2014 Set 2 Q31 | Producer-Consumer wait ordering creates deadlock |
| GATE CSE 2024 Set 2 Q36 | Blocking while holding a semaphore needed by another thread |
One thread can acquire s1 and then block on s2 while still holding s1. The other thread needs s1 before it can reach the signal on s2. Each side therefore waits for progress that the other cannot make.
Deadlock does not need to look exactly like wait(A), wait(B) versus wait(B), wait(A). The circular dependency may be indirect.
Which semaphore represents space, items and mutual exclusion?
Look for a bounded buffer, producer, consumer, empty, full, mutex, insertion or removal.
Assign the semantic role of each semaphore before reading the options: empty means free slots, full means available items, and mutex protects shared buffer state.
| GATE CSE PYQ | What it tests |
|---|---|
| GATE CSE 2002 Q20 | Identify P/V operations for full and empty slots |
| GATE CSE 2018 Q40 | Interpret empty, full and mutex roles |
If a bounded buffer begins empty, full starts at zero and empty starts at the buffer capacity. The producer consumes an empty slot before insertion and creates a full slot afterward. The consumer performs the reverse.
Acquire availability before mutex. Holding mutex while waiting for an empty or full slot can prevent the process that would create that condition from entering.
These questions test the same five reasoning patterns in different wording. The strongest additions are part of the focused practice set; a few clearly marked Extra Similar Practice questions are retained because they are valid semaphore drills even when their reasoning overlaps with an existing GATE pattern.
| Direct question | Pattern | Why it belongs |
|---|---|---|
| GATE IT GATE IT 2004 Q65 |
Pattern 5 | Producer-Consumer with full, empty and mutex |
| GATE IT GATE IT 2005 Q42 |
Pattern 3 | Minimum binary semaphores for alternating precedence |
| GATE IT GATE IT 2006 Q55 |
Pattern 4 | Producer-Consumer wait ordering and deadlock |
| GATE IT GATE IT 2007 Q56 |
Pattern 2 | Readers-Writers using mutex and wrt |
| GATE IT GATE IT 2008 Q53 |
Pattern 5 | Producer and consumer synchronized by binary semaphores |
| ISRO / UGC NET ISRO CSE 2007 Q42 / UGC NET June 2010 II Q37 |
Pattern 2 | Purpose of semaphores and contention |
| ISRO ISRO CSE 2016 Q45 |
Pattern 1 | Counting-semaphore arithmetic using P and V |
| ISRO ISRO CSE 2023 Q75 |
Pattern 5 | Primitive that makes a consumer wait on an empty buffer |
| UGC NET UGC NET January 2017 Part 2 Q36 |
Pattern 1 | Negative semaphore value and number of waiting processes |
| UGC NET UGC NET December 2019 Part 2 Q24 |
Pattern 1 | Counting-semaphore arithmetic drill |
| UGC NET UGC NET June 2025 Part 2 Q63 |
Pattern 2 | Spinlock semaphores and busy waiting |
| TIFR TIFR CSE 2012 Part B Q10 | Pattern 2 | Blocked-set semaphore: mutual exclusion versus starvation under arbitrary wake-up |
| UGC NET UGC NET June 2013 Part 3 Q60 Extra Similar Practice | Pattern 4 | Classic opposite semaphore acquisition order and deadlock |
| IIITH PGEE IIITH PGEE 2026 Q65 Extra Similar Practice | Pattern 4 | Deadlock-free execution with binary semaphores; similar reasoning to a GATE deadlock pattern |
| BARC BARC 2026 Q37 Extra Similar Practice | Pattern 2 | Basic mutual-exclusion drill on the initial semaphore value |
The selected DPPs stay tightly aligned to semaphore reasoning: value and blocking, mutual exclusion and correctness, ordering, deadlock, semaphore-based Readers-Writers, and Producer-Consumer.
Atomic wait/signal and semaphore correctness
Open direct question →Trace wait/signal operations and blocking
Open direct question →Alternating A/B ordering with two semaphores
Open direct question →Explicit precedence constraints across two processes
Open direct question →Negative semaphore convention and blocked-process count
Open direct question →Interpret empty, full and mutex
Open direct question →What empty, full and mutex each guarantee
Open direct question →Correct producer semaphore-operation order
Open direct question →Blocking on empty while holding mutex can deadlock
Open direct question →Analyze a modified reader-writer semaphore protocol
Open direct question →Roles of mutex, wrt and readcount
Open direct question →Final empty, full and mutex values after completed operations
Open direct question →Interrupt disabling, spinning, atomicity and progress
Open direct question →Want a single place to track what you have solved? Open the checklist below. The marking control is native HTML, so it does not depend on custom JavaScript.
Final counting-semaphore value after P/V operations
PractisedCounting-semaphore arithmetic
PractisedLargest initial value that still leaves a P operation blocked
PractisedBroken P/V usage and maximum processes in the critical section
PractisedCounting semaphore allows concurrent non-atomic updates
PractisedMultiple waits, limited permits and race behavior
PractisedBinary versus counting semaphore around shared updates
PractisedReaders-Writers protocol using semaphores
PractisedReaders-Writers, busy waiting and starvation
PractisedImplement a counting semaphore using binary semaphores
PractisedWhy semaphore operations must be atomic
PractisedImplement semaphore operations using an atomic primitive
PractisedConvert precedence constraints into semaphore synchronization
PractisedConvert P/V synchronization into a precedence graph
PractisedForce a repeating output sequence
PractisedRestrict possible output patterns
PractisedPossible executions and printed outputs
PractisedEnforce a producer-before-consumer style dependency
PractisedInitialize semaphores to enforce BCABC...
PractisedPossible output patterns with two binary semaphores
PractisedCircular wait among binary semaphores
PractisedSemaphore acquisition order and deadlock
PractisedOrdering multiple semaphore acquisitions
PractisedProducer-Consumer wait ordering creates deadlock
PractisedBlocking while holding a semaphore needed by another thread
PractisedIdentify P/V operations for full and empty slots
PractisedInterpret empty, full and mutex roles
PractisedProducer-Consumer with full, empty and mutex
PractisedMinimum binary semaphores for alternating precedence
PractisedProducer-Consumer wait ordering and deadlock
PractisedReaders-Writers using mutex and wrt
PractisedProducer and consumer synchronized by binary semaphores
PractisedPurpose of semaphores and contention
PractisedCounting-semaphore arithmetic using P and V
PractisedPrimitive that makes a consumer wait on an empty buffer
PractisedNegative semaphore value and number of waiting processes
PractisedCounting-semaphore arithmetic drill
PractisedSpinlock semaphores and busy waiting
PractisedAtomic wait/signal and semaphore correctness
PractisedTrace wait/signal operations and blocking
PractisedAlternating A/B ordering with two semaphores
PractisedExplicit precedence constraints across two processes
PractisedNegative semaphore convention and blocked-process count
PractisedInterpret empty, full and mutex
PractisedWhat empty, full and mutex each guarantee
PractisedCorrect producer semaphore-operation order
PractisedBlocking on empty while holding mutex can deadlock
PractisedAnalyze a modified reader-writer semaphore protocol
PractisedRoles of mutex, wrt and readcount
PractisedFinal empty, full and mutex values after completed operations
PractisedInterrupt disabling, spinning, atomicity and progress
PractisedBlocked-set semaphore: mutual exclusion versus starvation under arbitrary wake-up
PractisedClassic opposite semaphore acquisition order and deadlock
Deadlock-free execution with binary semaphores; similar reasoning to a GATE deadlock pattern
Basic mutual-exclusion drill on the initial semaphore value
Five short scenarios. Do not solve the numerical details. Identify the reasoning family first.
Every GATE CSE question in the focused semaphore set has one primary home. Questions that overlap multiple ideas are placed under the pattern that gives the best first attack.
| Pattern | Direct GATE Overflow links |
|---|---|
| 1. Value, P/V + Blocking | 1992 Q2(x) 1998 Q1.31 2016 Set 2 Q49 |
| 2. Mutual Exclusion + Correctness | 1997 Q6.8 2013 Q34 2021 Set 1 Q46 2023 Q28 1987 Q8a 2000 Q20 2008 Q63 1990 Q1-vii 2006 Q61 |
| 3. Ordering + Precedence | 1993 Q22 1995 Q19 2003 Q80 2003 Q81 2010 Q45 2013 Q39 2022 Q9 2026 Set 2 Q41 |
| 4. Deadlock + Wait Ordering | 2000 Q1.21 2004 Q48 2013 Q16 2014 Set 2 Q31 2024 Set 2 Q36 |
| 5. Producer-Consumer | 2002 Q20 2018 Q40 |
When you see a semaphore question, first decide whether it is about value and blocking, mutual exclusion and correctness, ordering, deadlock, or Producer-Consumer. Once that classification is right, the solution path is usually much shorter.