🎓 BookMCQ
← Back to 5. Process Synchronization

📝 Process Synchronization in Solaris (36 MCQs)

Solaris Kernel Synchronization and Locking Architecture

Solaris provides synchronization mechanisms for coordinating kernel threads and protecting shared operating system data structures. Its traditional kernel synchronization facilities include adaptive mutexes, condition variables, readers-writer locks, and semaphores. These mechanisms support different resource-access patterns and execution contexts, allowing the kernel to protect shared state while balancing processor utilisation, blocking overhead, and multiprocessor concurrency.

Why Solaris Uses Multiple Locking Strategies

Kernel operations vary in duration and execution context. Some critical sections are extremely short and benefit from spinning, while longer operations should allow waiting threads to sleep. Read-heavy structures also require efficient simultaneous access. Solaris uses different synchronization mechanisms to avoid unnecessary blocking, protect shared resources, and support scalable execution across multiple processors.

Adaptive Mutexes, Condition Variables, and Read-Write Locks

An adaptive mutex can spin while its owner is running on another processor, then block if the owner is not progressing. Condition variables allow threads to wait for specified events while releasing an associated lock. Readers-writer locks permit concurrent readers but require exclusive writer access, while semaphores coordinate resource counts and event ordering.

Choosing an Adaptive Mutex for a Short Critical Section

Suppose kernel thread T1 holds an adaptive mutex for a short operation on one CPU, while T2 requests the same lock on another CPU. T2 may spin briefly while T1 continues executing. If T1 stops running or the wait becomes unsuitable for spinning, T2 can block until the lock is released.

Multiprocessor Efficiency and Priority-Aware Synchronization

Solaris synchronization mechanisms support concurrent kernel execution, memory management, and resource coordination. Adaptive behaviour can avoid unnecessary sleeping when lock owners are actively progressing. However, spinning wastes CPU time if critical sections remain occupied too long. Priority-related blocking, lock ordering, and synchronization overhead must also be managed to preserve system responsiveness.

Misconceptions About Solaris Locking Mechanisms

'An adaptive mutex always makes waiting threads sleep' is incorrect because it may spin while the owner runs. 'Readers-writer locks permit concurrent writers' is incorrect because writers require exclusive access. 'Spinning is always more efficient than blocking' is incorrect because prolonged contention wastes processor capacity.

Exam Focus: Adaptive Mutex and Read-Write Lock Behaviour

Explain how an adaptive mutex chooses between spinning and blocking, and compare it with a conventional sleeping mutex. Trace reader and writer access under a readers-writer lock. Questions may examine condition variables, semaphore operations, multiprocessor contention, and why synchronization primitives must match the duration and context of protected operations.

Key Terms of Solaris Synchronization

  • Adaptive mutex - Lock combining spinning and blocking.
  • Condition variable - Coordinates event-based waiting.
  • Readers-writer lock - Allows shared reads and exclusive writes.
  • Semaphore - Synchronization through resource permits.
  • Spin - Repeatedly checks a lock condition.
  • Lock contention - Competition for protected access.
12
Easy
12
Medium
12
Hard

📝 All Process Synchronization in Solaris MCQs

Q1. A Solaris service runs four kernel threads that each add one to a shared counter 500 times. The final value is 1,842. Which explanation best accounts for the shortfall from 2,000?

A.The scheduler discards increments made by threads with lower priority
B.Concurrent read-modify-write sequences can overwrite one another when no synchronization protects the counter ✅
C.Each thread receives a private copy of every global variable whenever it is preempted
D.Integer counters stop accepting updates after a fixed number of context switches
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: An increment usually reads, changes, and writes the counter. Two threads can read the same old value and then overwrite one another's results. Protecting the complete update with a mutex or atomic operation prevents these lost increments.

Q2. Two Solaris processes map the same shared-memory queue, but each initializes a separate process-private mutex in its own address space. Why can both still modify the queue simultaneously?

A.The processes are not using the same synchronization object in genuinely shared memory with process-sharing configuration ✅
B.A mutex protects only integer variables and cannot protect queue structures
C.The operating system automatically merges separately allocated mutexes only after contention begins
D.A process-private mutex becomes shared whenever two processes use the same variable name
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Mutual exclusion works only when all participants coordinate through the same underlying object. Separately allocated process-private mutexes remain independent, even when they guard the same shared data. Interprocess coordination requires shared storage and compatible process-sharing setup.

Q3. In a Solaris kernel, when is brief spinning on an adaptive mutex most likely to be useful?

A.When the lock holder is blocked indefinitely on disk I/O
B.When the protected operation must permit several writers at once
C.When the owner is running on another CPU and is expected to release the short-held lock soon ✅
D.When the waiting thread must enter a long sleep before attempting acquisition
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Brief spinning can avoid sleep and wake-up overhead when the lock owner is actively running and likely to release the mutex soon. If the owner is not progressing, continued spinning wastes processor time and blocking is preferable.

Q4. A kernel developer estimates that spinning costs 100 CPU cycles per microsecond. Suspending and waking a waiter costs about 700 cycles. For an expected wait of 12 microseconds, which choice has the lower estimated cost?

A.Spin, because 12 microseconds always costs fewer than 700 cycles
B.The costs are equal because both methods involve a context switch
C.Spin, because 100 cycles is the cost of the entire wait regardless of duration
D.Block, because spinning costs about 1,200 cycles, exceeding the estimated 700-cycle blocking cost ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The estimated spin cost is 12imes100=1,20012 imes 100 = 1,200 cycles. Blocking costs about 700 cycles, so it is cheaper under these assumptions. A shorter expected wait could reverse the comparison, depending on actual scheduling and lock-release timing.

Q5. A Solaris data structure is searched by many threads and modified only occasionally. Which access pattern best justifies considering a reader-writer lock?

A.Multiple readers can safely overlap, while a writer needs exclusive access ✅
B.Writers can modify the structure simultaneously with every reader
C.Every read operation changes the shared structure
D.Only one thread is allowed to read or write at any time, even when no writer exists
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A reader-writer lock allows compatible read operations to overlap while excluding readers and other writers during modification. It is most useful when reads are frequent, writes are relatively rare, and the protected work justifies the added lock-management cost.

Q6. Readers R1 and R2 both hold a shared read lock when writer W requests exclusive access. What must be true before W can enter its protected write section?

A.W may enter immediately because readers do not modify the data
B.Both R1 and R2 must release their read locks so the writer can obtain exclusive ownership ✅
C.W can enter as long as it writes a different field
D.One reader must convert its shared lock into a semaphore permit for W
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A writer requires exclusive access, so it cannot enter while existing readers hold the shared lock. The readers must leave first. Whether new readers may join ahead of the writer depends on the lock's documented fairness policy.

Q7. A Solaris consumer waits for a producer to place an item in a shared queue. Which condition-variable design correctly coordinates the consumer?

A.Treat each condition-variable signal as a permanent record of one queued item
B.Read the queue count without a mutex after every wake-up
C.Protect the queue predicate with a mutex and recheck it in a loop after waking ✅
D.Assume a wake-up guarantees that the queue still contains an item
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The queue predicate records whether work actually exists; a condition variable only notifies a waiter that the state may have changed. The consumer checks the predicate while holding the mutex and repeats the check after each wake-up.

Q8. A consumer checks that a queue is empty while holding mutex M, unlocks M, and only afterward registers on condition variable C. A producer inserts an item and signals C in between. What flaw is present?

A.The producer has violated mutual exclusion by inserting an item
B.The condition variable has stored two notifications for one item
C.The consumer will necessarily consume the same item twice
D.The consumer can miss the signal and sleep even though the queue is no longer empty ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The separate unlock and wait-registration steps create a lost-wakeup window. A producer can change the predicate and signal before the consumer becomes a waiter. The condition wait must atomically release the mutex while blocking, followed by predicate rechecking.

Q9. A Solaris producer signals a condition variable while no consumer is waiting. A consumer begins waiting later. What should the consumer rely on to determine whether work exists?

A.The protected queue state or predicate, because the earlier signal is not a stored permit ✅
B.The old signal, which every condition variable retains until consumed
C.The number of times the producer previously called signal, even without shared state
D.The mutex owner field, which records how many queue entries are pending
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Condition-variable notifications are not generally accumulated like semaphore permits. A signal issued with no waiter may have no lasting effect. The durable information must be represented by shared state, checked under the associated mutex before waiting and after waking.

Q10. A Solaris semaphore represents six available identical devices. Four successful wait operations occur, followed by two successful post operations, with no other activity. What is the resulting permit count?

A.2
B.4 ✅
C.6
D.8
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Each successful wait consumes one permit and each post adds one. Starting from six, the count becomes 6−4+2=46 - 4 + 2 = 4. The result represents four available devices, assuming no operation failed or was interrupted.

Q11. A Solaris worker successfully waits on a semaphore for a device, then terminates before posting the permit. Other workers later remain blocked. Which explanation best fits the behavior?

A.The semaphore automatically identifies the worker and restores its permit
B.The semaphore changes into a mutex owned by the terminated worker
C.The permit may remain consumed because a semaphore does not generally track ownership for automatic recovery ✅
D.The operating system doubles every remaining permit after a worker exits
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: A semaphore records permits, not necessarily which thread owns each one. If a worker exits after consuming a permit without returning it, the count can stay reduced. An application needs cleanup or recovery logic for such failure paths.

Q12. A semaphore starts at 8. Three tasks each perform one successful wait but mistakenly perform two posts before finishing. Assuming no maximum-count failure or other activity, what is the final count?

A.5
B.8
C.10
D.11 ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Each task consumes one permit and returns two, producing a net increase of one. Across three tasks, the count changes by 3imes(2−1)=33 imes (2 - 1) = 3, so the final value is 8+3=118 + 3 = 11.

Q13. A Solaris application protects a counter and related status field with mutex M. One code path updates the counter using an atomic instruction without acquiring M. Why can the overall invariant still fail?

A.The atomic update does not follow the shared locking protocol and may interleave with the compound protected update ✅
B.Atomic instructions are ignored whenever a mutex exists in the same program
C.A mutex protects only status fields and cannot protect counters
D.An atomic instruction always waits until every mutex in the process is released
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: An atomic instruction protects its individual read-modify-write operation, not the relationship between the counter and status field. Mixing it with a separate mutex protocol can expose intermediate combinations. All conflicting paths must follow a compatible synchronization design.

Q14. A service uses one mutex for thousands of unrelated cache records. Profiling shows long waits but very short individual updates. Which redesign is most directly worth evaluating?

A.Remove the mutex and allow every thread to update any record
B.Partition records across appropriately chosen locks while preserving a consistent order for operations that touch several partitions ✅
C.Increase the number of threads while keeping the same single lock
D.Keep the mutex permanently locked after each record update
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A single mutex serializes independent record updates and can become a scalability bottleneck. Partitioning the state can allow unrelated operations to proceed concurrently. Operations spanning partitions still need a consistent locking protocol to preserve invariants and avoid deadlock.

Q15. Two Solaris threads may need mutexes A and B. One path acquires A before B, while another acquires B before A. Which policy most directly prevents this circular-wait pattern?

A.Let each thread choose whichever order is fastest at runtime
B.Increase both mutex hold times to reduce acquisition frequency
C.Define and enforce one global order for acquiring both mutexes ✅
D.Allow a thread to unlock a mutex owned by another thread
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A consistent global acquisition order prevents threads from forming the opposing dependency cycle in which each holds one mutex and waits for the other. It addresses this deadlock pattern, although contention and starvation may still require separate attention.

Q16. A thread acquires a Solaris mutex, but a different thread later attempts to release that mutex. What should the reviewer generally conclude about this design?

A.It guarantees FIFO fairness for all waiters
B.It converts the mutex into a counting semaphore
C.It is required whenever the lock protects shared memory
D.It violates ordinary mutex ownership rules and may be invalid for the mutex type ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: A mutex normally represents ownership as well as exclusion. Releasing it from a non-owner is not a valid general protocol and may be rejected or produce undefined behavior, depending on the primitive. The acquiring thread should perform the matching release.

Q17. Thread T1 updates two fields while holding mutex M, then unlocks M. Thread T2 later locks the same M before reading both fields. Which guarantee is central to this sequence?

A.The unlock and subsequent lock establish synchronization so T2 can observe T1's protected updates ✅
B.The scheduler guarantees T1 and T2 run on the same processor
C.The mutex automatically rolls back partial updates if T1 is interrupted
D.The two fields must contain identical values after every update
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The mutex provides mutual exclusion and a synchronization relationship between release and a later successful acquisition. When all conflicting accesses use the same protocol, T2 can observe T1's completed protected updates rather than an unsynchronized intermediate state.

Q18. A Solaris program protects writes to a configuration field with mutex M, but a reader accesses that field without M because reads are usually harmless. The writer occasionally changes it. What is the concern?

A.Read operations never conflict with writes, regardless of timing
B.The unsynchronized read can race with a write and observe an inconsistent or undefined value ✅
C.The mutex prevents the writer from changing the field
D.The reader automatically receives a private snapshot whenever it skips the mutex
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A read-only operation can still conflict with a concurrent write. Since the reader bypasses the synchronization protocol, it may observe an inconsistent value or create a data race. Immutable publication, atomic access, or consistent locking is required.

Q19. A Solaris service publishes a new immutable configuration snapshot and immediately frees the old snapshot. Some readers may still hold pointers to the old version. What essential step is missing?

A.The writer must modify the old snapshot before publication
B.Every reader must hold the writer's exclusive lock for the entire process lifetime
C.The old version must remain valid until all pre-existing readers have finished using it ✅
D.The new snapshot must be allocated at the same address as the old one
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Publishing a replacement does not prove that readers have stopped using the previous version. Reclamation must wait for a safe point, such as a grace period or equivalent lifetime protocol, or readers may dereference freed memory.

Q20. A producer-consumer queue stores both its items and a separate count. Which practice best prevents the count from drifting away from the actual queue contents?

A.Increment the count before deciding whether insertion succeeds
B.Let consumers decrement the count twice to avoid underflow
C.Reset the count whenever a condition variable is signaled
D.Update the queue and count consistently under the same synchronization protocol, then check the count before removal ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: The queue and count describe related state and must change consistently. Protecting both under one suitable protocol prevents consumers from relying on stale information and maintains the invariant that the count matches the number of available items.

Q21. A Solaris thread repeatedly polls a shared flag in a tight loop while waiting for another thread to finish. CPU usage remains high, but no useful work is performed. What is happening?

A.Busy-waiting is consuming processor cycles that a blocking wait could avoid ✅
B.The flag has automatically become a counting semaphore
C.The waiting thread has guaranteed exclusive access to the flag
D.The processor has disabled context switching for the entire process
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A tight polling loop repeatedly consumes CPU time while waiting for a state change. For longer waits, a condition variable, semaphore, or other blocking mechanism can suspend the waiter and let the processor execute useful work.

Q22. A thread repeatedly requests a resource and is bypassed by other threads each time it becomes available. Those other threads continue completing work. Which problem does this describe?

A.Deadlock, because no thread in the system can make progress
B.Starvation, because one thread is indefinitely denied access while others progress ✅
C.A lost wake-up, because every signal must be stored permanently
D.Mutual exclusion, because more than one thread owns the resource
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Starvation occurs when a particular thread is continually denied access despite overall system activity. Unlike deadlock, other threads can keep progressing. Fair allocation, bounded waiting, or a revised acquisition policy may be needed to prevent it.

Q23. Two Solaris kernel threads access a linked list. One inserts a node while the other traverses the list, and neither uses synchronization. What is the most serious risk?

A.The list automatically becomes circular whenever two threads access it
B.The scheduler guarantees that traversal completes before insertion starts
C.The traversal may observe inconsistent pointers or access a node whose lifetime is no longer valid ✅
D.Every allocated node becomes immutable after its first read
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Insertion changes multiple pointer relationships, so an unsynchronized traversal can observe an intermediate structure or follow an invalid pointer. Correct protection must coordinate structural changes, traversal, and memory reclamation rather than merely protect the new node.

Q24. A kernel service holds mutex M while updating a record and writing a diagnostic message to a slow device. Several unrelated threads then wait on M. What redesign best preserves correctness while reducing avoidable blocking?

A.Remove M from every record update
B.Increase the number of diagnostic messages so the lock owner finishes sooner
C.Hold M until the device confirms that every message has been physically written
D.Copy the needed diagnostic data while protected, release M, and perform the slow output afterward when safe ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Slow output extends the lock hold time and can create additional lock-order dependencies. When correctness permits, capture the information needed for logging while protected, release the mutex, and perform the potentially blocking output afterward.

Q25. A Solaris service records throughput as thread count increases. Data: (1,120 requests/s); (2,220); (4,390); (8,610); (16,625); (32,620). Which interpretation best fits the trend?

A.Throughput initially benefits from concurrency, then levels off as contention or another shared bottleneck limits scaling ✅
B.The measurements prove that every thread executes serially from the beginning
C.The drop after 16 threads proves the service has stopped using mutexes
D.Throughput must double whenever the thread count doubles, so the measurements are impossible
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Throughput rises as concurrency increases, then changes very little beyond eight threads. This pattern suggests that lock contention, serialized work, memory bandwidth, or another shared resource is limiting additional parallelism rather than thread count alone.

Q26. A monitor records this trace: time 0, waiters 1 and completions 12; time 1, waiters 3 and completions 12; time 2, waiters 5 and completions 12; time 3, waiters 7 and completions 12; time 4, waiters 9 and completions 12. What is the strongest diagnosis?

A.The system is scaling ideally because more waiters indicate higher throughput
B.Progress appears stalled while requests accumulate; inspect lock ownership, blocked dependencies, and missed release paths ✅
C.The trace proves that every waiting thread owns the same mutex
D.The queue is empty because completion count remains constant
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A rising waiter count with no additional completions indicates stalled progress while demand continues. The trace alone does not prove a specific deadlock, but it warrants checking held locks, dependency cycles, ownership, and missing cleanup or release paths.

Q27. A benchmark varies the fraction of operations that are writes: (0%,1000 ops/s); (10%,970); (20%,910); (40%,780); (60%,620); (80%,430). What does the pattern suggest about a reader-writer lock?

A.Its advantage grows as writes become the majority
B.Writers can safely overlap because the read fraction is falling
C.Its shared-reading advantage becomes less useful as exclusive writes occupy more of the workload ✅
D.The data proves the lock is not providing mutual exclusion
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: As the write fraction rises, more operations require exclusive access and fewer can benefit from concurrent reading. A reader-writer lock is most attractive for read-heavy workloads; frequent writes can reduce its concurrency advantage and add bookkeeping overhead.

Q28. A measurement gives spin costs of 100 cycles per microsecond: (1 us,100 cycles); (2,200); (4,400); (8,800); (16,1600). If blocking costs about 800 cycles, at what wait duration do the estimates become equal?

A.2 microseconds
B.4 microseconds
C.16 microseconds
D.8 microseconds ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The estimated spin cost equals the blocking cost when 100t=800100t = 800, giving t=8t = 8 microseconds. Below that estimate, spinning may cost less; above it, blocking may be cheaper, subject to real scheduling and wake-up variation.

Q29. A Solaris application divides work into repeated phases. Every worker must finish the current phase before any worker begins the next. Which synchronization primitive most directly represents this requirement?

A.A barrier configured for the participating threads ✅
B.A mutex permanently held by the first worker
C.A semaphore initialized to an arbitrary negative count
D.A busy loop that estimates when the slowest worker will finish
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A barrier provides a rendezvous point for a defined group of participants. Threads wait until the required arrivals occur, then continue to the next phase. It coordinates phase completion but does not automatically protect unrelated shared data.

Q30. A producer can add four jobs before any consumer begins waiting. The system must ensure that all four jobs remain discoverable. Why is a condition variable signal alone insufficient as the job count?

A.A condition variable always releases exactly four consumers per signal
B.Notifications are not accumulated as four permits; maintain the queue predicate or use a counting semaphore for per-job availability ✅
C.A condition variable can only be used when the queue contains no jobs
D.The mutex automatically counts each signal and stores the job payload
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A condition variable is a notification mechanism, not a stored count of pending events. The queue itself must record the four jobs and be checked under its mutex, or a counting semaphore can represent the available job permits.

Q31. A Solaris driver manages several identical devices and also maintains a linked list describing each device's owner. Which design best separates the two synchronization responsibilities?

A.Use a condition variable as both the device count and list lock
B.Use one unprotected integer for the permits and rely on scheduling for the list
C.Use a counting semaphore for available devices and a mutex for consistent updates to the ownership list ✅
D.Use a barrier to grant devices and a spin loop to protect list pointers
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The counting semaphore represents how many devices are available, while the mutex protects compound updates to the ownership list. They serve different purposes and can be combined, provided acquisition order and failure cleanup preserve the resource accounting.

Q32. Kernel thread T1 holds a short-lived adaptive mutex and is currently running on another CPU. Thread T2 requests the same mutex. Which response is most consistent with the adaptive strategy described in Solaris synchronization?

A.T2 immediately enters the critical section because T1 is on another CPU
B.T2 must always sleep before its first lock attempt
C.T2 disables the other CPU until T1 releases the mutex
D.T2 may spin briefly while T1 runs, then block if the owner is not progressing ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: An adaptive mutex can use a short spin when its owner is executing on another processor and may release the lock soon. If the owner is not running or the wait persists, blocking avoids wasting CPU cycles.

Q33. Thread T1 successfully waits on a Solaris semaphore representing a pending event. Thread T2 later posts the semaphore when the event occurs. Which statement best distinguishes this from ordinary mutex ownership?

A.A semaphore represents permits or events and does not generally require the posting thread to be the thread that previously waited ✅
B.Only the original waiter is permitted to post the semaphore
C.Posting transfers mutex ownership from T1 to T2
D.The semaphore cannot be changed by a different thread
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A semaphore coordinates through a count of permits or events rather than exclusive ownership by one thread. A different thread can post to make a permit available, whereas a mutex normally follows an owner-based acquire and release protocol.

Q34. A shared table is read thousands of times per second, updated once per minute, and each read performs substantial work. Which choice is most likely to benefit from a reader-writer lock?

A.A workload in which every operation writes a different table field
B.A read-dominant workload where overlapping readers can amortize the extra lock-management overhead ✅
C.A workload where each read must exclude all other readers
D.A workload consisting only of one very short operation
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Frequent, substantial read operations can overlap under a reader-writer lock, while occasional writes obtain exclusive access. The read-heavy workload can justify the extra bookkeeping; very short or write-heavy operations may gain little from this primitive.

Q35. A code review finds that function F locks mutex M before changing a shared record, but function G changes the same record without locking M. The developer claims the record is protected because F uses a mutex. What is the correction?

A.A mutex protects every function in the process once it is initialized
B.Only write operations in function F need synchronization, regardless of other access paths
C.Every conflicting access must follow a compatible synchronization protocol; F's lock cannot protect G when G bypasses it ✅
D.The scheduler will automatically delay G until F unlocks M
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A mutex protects data only when conflicting code paths use the same synchronization protocol. Function G can still race with F because it bypasses the lock. All readers and writers must coordinate, or the data needs another safe design.

Q36. A cache reader acquires read lock R and then requests metadata mutex M. A cache writer acquires M first and then requests R exclusively. Under contention, what single policy change most directly removes this lock-order cycle?

A.Allow the writer to ignore R whenever M is held
B.Make both locks recursive so each thread can reacquire them
C.Have the reader release R while continuing to access the protected cache
D.Require every path needing both locks to acquire R first and M second, with the writer taking R exclusively ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Reader holds R awaiting M; writer holds M awaiting exclusive R, forming a cycle. Enforce R-before-M ordering on all paths so neither can hold the later lock while waiting for the earlier lock.

🔗 Related Topics (MCQs)