🎓 BookMCQ
← Back to 5. Process Synchronization

📝 The Critical Section Problem in Process Synchronization (36 MCQs)

Protecting Shared Data During Critical-Section Execution

The critical-section problem concerns designing a protocol that controls access to shared data when multiple processes execute concurrently. Each process contains a critical section where it accesses or modifies shared resources, together with entry and exit sections. The synchronization protocol determines which process may enter, preventing conflicting operations while allowing independent processes to continue performing noncritical work.

Why Uncontrolled Entry Produces Inconsistent Results

Concurrent execution allows instructions from different processes to interleave in unpredictable orders. If two processes update the same shared variable simultaneously, one update may overwrite the other. A correct protocol must coordinate entry without unnecessarily preventing progress or allowing one process to wait indefinitely while others repeatedly enter.

Entry, Critical, Exit, and Remainder Sections

A process first executes its entry section to request permission to access protected data. After receiving permission, it executes the critical section and then performs its exit section to release access. It subsequently executes its remainder section independently. The protocol must enforce mutual exclusion, progress, and bounded waiting under its stated execution assumptions.

Preventing Lost Updates in a Shared Balance

Suppose two processes withdraw 100 units from a shared balance of 1,000. Without protection, both may read 1,000 and independently write 900, losing one withdrawal. A critical-section protocol ensures that the first process completes its update before the second reads the balance, producing the correct final balance of 800.

Fairness, Safety, and Processor Utilisation

Critical-section protection maintains consistency in shared counters, process tables, kernel structures, and database records. Mutual exclusion prevents overlapping protected operations, while progress and bounded waiting address coordination and fairness. However, long critical sections reduce concurrency, busy waiting wastes processor cycles, and poorly designed protocols can introduce deadlocks or starvation.

Misconceptions About Critical-Section Correctness

'Mutual exclusion alone guarantees a correct protocol' is incorrect because progress and bounded waiting also matter. 'A process must always enter the critical section eventually' is incorrect because eligibility depends on protocol conditions. 'The remainder section requires mutual exclusion' is incorrect because it contains operations outside the protected region.

Exam Focus: Testing the Three Critical-Section Conditions

Identify the entry, critical, exit, and remainder sections in a concurrent program. Evaluate a proposed solution against mutual exclusion, progress, and bounded waiting separately. Questions may present execution traces, shared-variable updates, or pseudocode and ask whether two processes can enter simultaneously, whether selection can proceed, or whether waiting is bounded.

Key Terms of the Critical-Section Problem

  • Entry section - Requests permission to enter.
  • Exit section - Releases protected access.
  • Critical section - Performs shared-resource operations.
  • Remainder section - Executes unrelated process work.
  • Mutual exclusion - Allows one protected entrant.
  • Bounded waiting - Restricts indefinite postponement.
12
Easy
12
Medium
12
Hard

📝 All The Critical Section Problem in Process Synchronization MCQs

Q1. [Process structure] A process repeatedly performs shared-data work. Which order correctly places the request for permission, protected work, release of permission, and unrelated computation?

A.Entry section, critical section, exit section, remainder section ✅
B.Critical section, entry section, remainder section, exit section
C.Entry section, exit section, critical section, remainder section
D.Remainder section, entry section, exit section, critical section
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The entry section requests permission; the critical section accesses protected shared state; the exit section relinquishes permission; and the remainder section performs unrelated work. This order clearly separates coordination from ordinary computation.

Q2. [Entry section] A thread must request access before updating a shared inventory record. Which part of its execution contains the permission request and any waiting needed before the update?

A.Remainder section
B.Exit section
C.Critical section
D.Entry section ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: The entry section contains the protocol used to request permission to access protected data. A process may wait there until admission is safe; the shared update itself belongs in the critical section.

Q3. [Exit section] A process has finished modifying a protected shared record. What is the main purpose of the code that follows the critical section immediately?

A.To repeat the shared update until it succeeds
B.To perform unrelated calculations before requesting access
C.To release or announce availability of the protected resource ✅
D.To prevent the scheduler from interrupting other processes
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The exit section performs the actions that relinquish the process claim on the critical section. This lets an eligible contender proceed, while unrelated work should remain outside the protected region.

Q4. [Remainder section] A banking process finishes its protected balance update and then formats a private receipt using local variables only. Where does receipt formatting belong?

A.Entry section
B.Critical section
C.Exit section
D.Remainder section ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Receipt formatting uses only process-local data and does not require coordinated access to the shared balance. It therefore belongs in the remainder section, after the protected operation and its exit protocol.

Q5. [Mutual exclusion] Two processes access the same shared structure, and simultaneous updates could corrupt its links. Which condition must a correct critical-section protocol guarantee?

A.Every process enters after exactly the same delay
B.A process inside the section cannot be preempted
C.Processes execute their remainder sections in a fixed order
D.Only one participating process executes the protected section at a time ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Mutual exclusion requires that at most one participating process execute the relevant critical section at any moment. It does not require equal delays or uninterrupted execution, and preemption may occur safely.

Q6. [Mutual exclusion application] Two warehouse workers read a stock value of 1, each decide that one item is available, and both decrement it. Which protection would prevent this conflicting sequence?

A.Coordinate the complete check-and-decrement operation as one protected critical section ✅
B.Delay each worker by a different fixed number of milliseconds
C.Allow both workers to read freely and protect only the final display
D.Give one worker a higher CPU priority than the other
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The availability check and decrement form one logical operation on shared state. Protecting the whole sequence prevents both workers from acting on the same old value and selling more items than remain.

Q7. [Graph: mutual exclusion] A plot gives time and the number of processes simultaneously inside one critical section: (0,0); (1,1); (2,2); (3,1); (4,0); (5,0). Which observation proves a violation?

A.The count is zero at time 0
B.The count returns to zero at time 4
C.The count is two at time 2 ✅
D.The count is one at time 3
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: At time 2, the plotted count is two, so two processes occupy the same protected region simultaneously. That directly violates mutual exclusion; the zero and one counts do not demonstrate overlapping execution.

Q8. [Error analysis] A student writes code that locks a shared record, changes its status, unlocks it, and only then writes the new owner identifier. What is the flaw?

A.The lock should be acquired after both writes
B.The owner identifier must be stored in a private variable
C.The status field should never be changed
D.The lock is released before the complete shared-state update finishes ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The flawed step is unlocking before writing the owner identifier. The correct boundary keeps both related writes protected, so another process cannot observe or modify a partially updated record during the operation.

Q9. [Mixed: shared invariant] An online store transfers one unit from available stock to reserved stock. Which design best preserves the invariant that available plus reserved stock remains unchanged during each transfer?

A.Protect only the available-stock decrement and leave the reserved increment uncoordinated
B.Protect the decrement and increment together as one critical section ✅
C.Protect only the final total displayed to customers
D.Perform the two updates in separate processes to increase concurrency
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The two fields represent one logical stock transfer and share an invariant. Keeping both updates inside the same critical section prevents another process from observing the temporary state between decrementing available stock and incrementing reserved stock.

Q10. [Error analysis] A shared record has fields balance and status. A writer updates both while protected, but a reader accesses them without using the same coordination protocol. What risk remains?

A.The writer is guaranteed to lose CPU time
B.The reader may observe fields from inconsistent moments of the update ✅
C.Mutual exclusion between writers automatically protects every reader
D.The record becomes immutable after the first write
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The writer-only protocol does not coordinate the reader with the update. The reader may observe one new field and one old field; readers must use compatible synchronization or a safe snapshot mechanism.

Q11. [Critical-section boundary] A consumer checks that a shared queue is nonempty and then removes its first item. Another consumer may act between these steps. What should be protected together?

A.The emptiness check and removal as one operation ✅
B.Only the print statement after removal
C.Only the consumer local-variable initialization
D.The entire lifetime of every consumer process
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The queue check and removal depend on the same shared state. Protecting them together prevents a second consumer from removing the final item after the first consumer checks, leaving the first with an invalid assumption.

Q12. [Critical-section scope] A process updates a shared counter and then compresses a private log buffer for several seconds. Which design is generally preferable?

A.Keep the shared-data protection active during all compression
B.Disable scheduling until compression is complete
C.Release protection after the counter update, before private compression ✅
D.Require every other process to compress its own buffer first
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Only the counter update requires coordinated access. Releasing protection before private compression shortens the critical section, reduces contention, and lets other processes use the shared counter without affecting the log operation.

Q13. [Progress] The critical section is empty and several processes request entry. Which requirement says that choosing the next entrant must not be postponed indefinitely?

A.Mutual exclusion
B.Bounded storage
C.Progress ✅
D.Preemption
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Progress requires a decision among eligible requesters when no process occupies the critical section. That decision cannot be delayed forever, and processes doing unrelated remainder work must not prevent admission.

Q14. [Error analysis] A two-process protocol forces strict alternation. P1 leaves its critical section, making P0 next; P0 performs a long private calculation, while P1 requests entry again and must wait. What is wrong?

A.The protocol violates progress because an uninterested process controls admission ✅
B.The protocol violates mutual exclusion because P1 is waiting
C.The protocol violates bounded waiting because P0 is doing private work
D.The protocol violates data integrity because P0 uses local variables
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The flawed rule makes P1 depend on P0 even though P0 has no pending request. Progress requires that a process in its remainder section cannot unnecessarily prevent an eligible requester from entering.

Q15. [Progress] A critical section is free. Process A requests entry, but the protocol waits for process B to change a shared indicator; B is performing unrelated remainder work and has not requested entry. Which requirement is endangered?

A.Mutual exclusion
B.Atomic file access
C.Bounded address space
D.Progress ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: B is not competing for the critical section, yet its unrelated activity determines whether A can proceed. This violates the progress principle that only interested contenders should influence the admission decision.

Q16. [Graph: progress] At every sample, the critical section is empty and two requests remain pending. The plot shows time and cumulative admissions: (0,0); (1,0); (2,0); (3,0); (4,0); (5,0). Assume this pattern continues indefinitely. What fails?

A.Mutual exclusion, because no process enters
B.Bounded waiting only, because two requests exist
C.Progress, because no eligible requester is ever selected ✅
D.Data consistency, because the admission count is constant
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The section stays empty while eligible requests remain pending and no admission occurs indefinitely. The selection decision is postponed forever, which is a progress failure rather than evidence of overlapping access.

Q17. [Mixed: safety and liveness] A coordinator grants entry to only one process at a time, but then stops responding while the critical section is free and several processes are waiting. Which conclusion is most accurate?

A.Mutual exclusion is necessarily violated
B.The protocol still guarantees bounded waiting
C.Progress can fail even though mutual exclusion is preserved ✅
D.All waiting processes enter simultaneously after the failure
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Single-grant behavior can preserve the safety condition of mutual exclusion. If the coordinator never selects another requester, however, the empty critical section remains unused and progress is not guaranteed for waiting processes.

Q18. [Challenging: progress] Process P is waiting to enter an empty critical section. The algorithm will admit P only after process R changes a flag, but R has no request pending and may remain in its remainder section indefinitely. What is the key defect?

A.P can overlap with R inside the critical section
B.The decision depends on a process that is not interested in entering ✅
C.The protocol necessarily gives P bounded waiting
D.R must be moved into the critical section first
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The admission decision depends on R even though R is not requesting access. Since R may remain in unrelated work, P can wait indefinitely while the section is free, violating progress.

Q19. [Bounded waiting] After a process requests entry, what does bounded waiting place a limit on?

A.The number of instructions the process executes inside its section
B.The number of other critical-section entries allowed before its request is granted ✅
C.The number of processors in the system
D.The elapsed time required for every process to finish all work
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Bounded waiting limits how many times other processes may enter after a request is made and before that request is granted. It prevents unlimited overtaking, rather than specifying a fixed elapsed-time deadline.

Q20. [Bounded-waiting application] A protocol claims a waiting process can be bypassed by at most two other entries. P requests access, but three other critical-section entries occur before P is admitted. What follows?

A.The stated bound is violated by the third bypass ✅
B.The protocol satisfies the bound because P eventually enters
C.Only mutual exclusion can be evaluated from this sequence
D.The third entry resets P request automatically
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The claimed maximum is two other entries after P requests access. A third entry occurs before P is admitted, so the protocol exceeds its stated bound even though P eventually enters.

Q21. [Graph: bounded waiting] P has requested entry, and the plot shows the cumulative number of entries by other processes: (0,0); (1,1); (2,1); (3,2); (4,3); (5,4). If the permitted bound is 3, when is it first exceeded?

A.At sample 1, when the count becomes 1
B.At sample 3, when the count becomes 2
C.At sample 4, when the count becomes 3
D.At sample 5, when the count becomes 4 ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: A bound of three allows at most three other entries before P is admitted. The plotted count first exceeds three at sample 5, where four other entries have occurred, so the bounded-waiting guarantee has failed.

Q22. [Error analysis] A student argues that bounded waiting is guaranteed because some process always enters whenever the critical section becomes free. Which correction is best?

A.That argument proves that no process can be interrupted
B.That argument proves every requester has a fixed time deadline
C.Bounded waiting concerns only the number of processes in the system
D.System-wide progress does not prove that one particular requester cannot be bypassed indefinitely ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The student confuses progress with bounded waiting. Progress ensures that some eligible process proceeds; bounded waiting adds an individual guarantee limiting how many other entries may occur before a particular waiting request is served.

Q23. [Bounded waiting] A protocol guarantees that no request is passed by more than four other entries. Which statement does this guarantee establish most directly?

A.A request completes within four milliseconds
B.No process can ever be preempted
C.The critical section is always occupied
D.The number of other entries before a waiting request is served is limited ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The guarantee limits overtaking by other critical-section entries. It does not establish a wall-clock deadline, because processor scheduling and execution speeds can affect elapsed time even when the number of bypasses is bounded.

Q24. [Fair admission] Three requests receive positions 10, 11, and 12 in an ordered waiting line. If request 11 is waiting, what does strict service in line order guarantee about request 12?

A.Request 12 cannot be served before request 11 ✅
B.Request 12 must enter before request 10
C.All three requests enter the critical section together
D.Request 11 can be ignored whenever new requests arrive
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Strict service order prevents a later request from overtaking an earlier pending request. Request 12 must wait until request 11 has been served, which supports bounded overtaking when the queue advances correctly.

Q25. [Execution assumptions] Two processes may run at very different speeds, and neither speed is known in advance. What must a correct critical-section solution avoid assuming?

A.That every process has a unique identifier
B.That all processes execute at the same relative speed ✅
C.That protected data may be shared
D.That processes can request entry more than once
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A correct protocol cannot rely on one process being faster or slower than another. It must preserve its guarantees across possible execution interleavings without requiring equal processor speeds or predictable timing.

Q26. [Error analysis] A team tests a critical-section algorithm for billions of executions without observing overlap and declares it formally correct. What is the flaw in this reasoning?

A.Testing cannot detect any concurrency defect
B.Mutual exclusion is needed only in single-processor systems
C.A large test suite cannot examine every possible execution interleaving or replace a correctness argument ✅
D.Formal reasoning applies only to arithmetic instructions
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The flawed step equates many successful tests with proof of correctness. Testing samples executions; a valid argument must establish the required properties for every permitted interleaving and the assumptions of the implementation.

Q27. [Graph: contention] A server is tested with the same workload and number of contenders. The plot gives average critical-section duration and average waiting time in milliseconds: (1,2); (2,4); (3,8); (4,15); (5,25); (6,39). Which trend is supported?

A.Longer protected regions are associated with sharply increasing average waiting time ✅
B.Waiting time remains constant as protected duration increases
C.Shortening a critical section necessarily breaks mutual exclusion
D.The graph proves bounded waiting for every individual request
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Across the measured workload, average waiting rises from 2 to 39 milliseconds as protected duration grows from 1 to 6 milliseconds. Longer occupancy leaves contenders waiting longer, although the graph alone cannot prove fairness.

Q28. [Mixed: interleavings] A programmer assumes that two processes cannot read the same old shared value because their instructions usually execute at different times. Which response is technically sound?

A.The assumption is safe whenever the processes have different priorities
B.The assumption is safe if each process contains a delay
C.Concurrent operations can interleave, so correctness must not depend on convenient timing ✅
D.The operating system automatically serializes all shared-variable instructions
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Processes can be interleaved at instruction boundaries in ways that make both read the same old value. A correct protocol must handle all permitted schedules instead of relying on typical timing or priority differences.

Q29. [Safety and liveness] Which classification best describes the three standard correctness requirements for the critical-section problem?

A.Mutual exclusion is a liveness property; progress and bounded waiting are safety properties
B.All three requirements describe only execution speed
C.Progress is a data-integrity property; bounded waiting is a memory-capacity property
D.Mutual exclusion is safety; progress and bounded waiting are liveness requirements ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Mutual exclusion prevents an unsafe overlap, making it a safety condition. Progress and bounded waiting concern whether eligible requests can advance and avoid indefinite postponement, so they express liveness requirements.

Q30. [Mixed: evaluate a trace] In a trace, no two processes overlap in the critical section, and every requester eventually enters. However, one request can be passed by an arbitrarily large number of later entries. Which assessment is correct?

A.Mutual exclusion and bounded waiting hold, but progress fails
B.Mutual exclusion and progress hold, but bounded waiting fails ✅
C.Progress and bounded waiting hold, but mutual exclusion fails
D.All three requirements fail because one request waits
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: No overlap satisfies mutual exclusion, and eventual admission for some eligible requester is consistent with progress. An arbitrarily large number of bypasses means there is no finite waiting bound for the affected request.

Q31. [Scenario: critical-section boundary] An order-processing thread decreases available stock, increases reserved stock, and then sends a receipt over a slow network. Which work should remain inside the critical section?

A.Only sending the receipt
B.The two related stock updates, but not the unrelated network transmission ✅
C.The entire lifetime of the order-processing thread
D.Only the formatting of the customer name
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The stock decrement and reservation increment jointly preserve the inventory invariant, so they must be coordinated as one operation. Network transmission does not modify that shared state and should occur after protection is released.

Q32. [Challenging: preserve an invariant] A buffer has capacity 20, with 8 occupied slots and 12 free slots. A producer inserts one item by decrementing free and incrementing occupied. Why should both counter updates be protected together?

A.To keep free plus occupied equal to 20 throughout the logical update ✅
B.To ensure the producer always runs before every consumer
C.To prevent the operating system from preempting the producer
D.To make the two counters use identical memory addresses
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The invariant is free plus occupied equals 20. If another process observes the state between the two writes, the reported total may temporarily be 19 or 21; protecting both writes preserves the logical invariant.

Q33. [Error analysis] A warehouse program checks that stock is positive before acquiring protection, then enters the critical section and decrements stock without checking again. Two workers may execute concurrently. What must be corrected?

A.Move the check inside the same protected region as the decrement ✅
B.Keep the check outside but add a longer delay
C.Remove the decrement and update only the display
D.Allow each worker to use a separate copy of the stock value
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The flawed step is checking availability before entering the protected region. Another worker can change stock before the decrement; the correct sequence performs both the check and decrement while access is coordinated.

Q34. [Scenario: shared record] A monitoring service updates a sensor value and its timestamp as a pair. A reporting thread must never display a new value with an old timestamp. What is the appropriate critical-section boundary?

A.Protect only the timestamp update
B.Protect only the reporter formatting code
C.Protect the value and timestamp update as one coordinated operation, and coordinate the paired read ✅
D.Allow the reporter to read at arbitrary points because it does not write
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The value and timestamp form one logical record, so updates must be coordinated together. The reader also needs compatible protection or a consistent snapshot to avoid combining fields from different update versions.

Q35. [Critical-section size] A process holds shared-state protection while waiting for a remote server response, although the response is unrelated to the protected data. What is the main consequence?

A.Mutual exclusion is automatically lost
B.The protected region is longer than necessary, increasing contention and delaying other requesters ✅
C.All waiting processes become guaranteed to enter in FIFO order
D.The remote server becomes part of the operating system scheduler
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The remote wait does not require exclusive access to the shared state. Holding protection during that delay lengthens the critical section, increases contention, and can reduce concurrency without improving correctness.

Q36. [Integrated scenario] Three tasks share a data structure. Task A updates two linked fields that must remain consistent, task B reads those fields together, and task C changes only its private local variable. Which design is sound?

A.Protect only A first field and let B read both fields without coordination
B.Protect A complete paired update and coordinate B paired read; C needs no protection for its private variable ✅
C.Make all three tasks enter the same critical section for every instruction
D.Protect only C because it executes independently
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A paired update and paired read must follow compatible coordination so B cannot observe an inconsistent combination. Task C touches only private state, so placing it in the same critical section would add unnecessary contention.

🔗 Related Topics (MCQs)