πŸŽ“ BookMCQ
← Back to 5. Process Synchronization

πŸ“ Process Synchronization in Solaris (51 MCQs)

πŸ“– From Operating System β€’ 5. Process Synchronization β€’ 51 questions available

What is Process Synchronization in Solaris?

Definition:
Solaris process synchronization includes adaptive mutexes, reader-writer locks, and turnstiles that dynamically switch between spinning and sleeping based on lock holder state and CPU availability.

Example:
An adaptive mutex spins briefly if the owner is running on another CPU, then sleeps via turnstile if the owner is preempted, avoiding wasted spin cycles TspinT_{spin}.

Reason:
Adaptive behavior optimizes for SMP environments where short critical sections benefit from spinning but long holds require sleeping, balancing latency and throughput automatically.

13
Easy
24
Medium
14
Hard

πŸ“ All Process Synchronization in Solaris MCQs

Q1. Which synchronization mechanism in Solaris is specifically designed to protect critical data items accessed by short code segments?

A.Semaphore
B.Condition Variable
C.Adaptive Mutex βœ…
D.Reader-Writer Lock
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Adaptive mutexes are optimized for short critical sections where the lock is held for less than a few hundred instructions, minimizing overhead compared to heavier mechanisms.

Q2. On a multiprocessor system, what determines whether an adaptive mutex will spin or block when a lock is unavailable?

A.The number of CPUs available
B.The run state of the thread holding the lock βœ…
C.The priority of the waiting thread
D.The length of the code segment
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: If the lock holder is running on another CPU, the waiting thread spins. If the holder is not running (sleeping), the waiting thread blocks to avoid wasting CPU cycles.

Q3. Why does an adaptive mutex always cause a thread to sleep rather than spin on a single-processor system?

A.Spinning consumes too much memory
B.Only one thread can run at a time βœ…
C.Single processors do not support spinlocks
D.The kernel disables interrupts on single processors
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: On a single-processor system, if a thread is testing a lock, the thread holding the lock cannot be running simultaneously. Therefore, spinning is futile, and sleeping is the only efficient option.

Q4. What is the primary efficiency advantage of reader-writer locks over semaphores for data that is frequently read?

A.They require less memory
B.They allow multiple threads to read data concurrently βœ…
C.They eliminate the need for context switches
D.They automatically handle priority inversion
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Semaphores serialize all access, allowing only one thread at a time. Reader-writer locks permit multiple readers to access data simultaneously, improving throughput for read-heavy workloads.

Q5. Why are reader-writer locks typically reserved for longer sections of code in Solaris?

A.They are incompatible with short loops
B.They are relatively expensive to implement βœ…
C.They cause priority inversion frequently
D.They do not support multiprocessor systems
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The implementation complexity and overhead of reader-writer locks make them inefficient for short operations. They are justified only when the critical section is long enough to benefit from concurrent read access.

Q6. What is a turnstile in the context of Solaris synchronization?

A.A hardware register for locking
B.A queue structure containing threads blocked on a lock βœ…
C.A type of adaptive mutex
D.A priority scheduling algorithm
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: A turnstile is a software queue structure that manages threads waiting to acquire a specific lock, such as an adaptive mutex or reader-writer lock.

Q7. How does Solaris optimize the association of turnstiles to synchronized objects?

A.Each object has a dedicated permanent turnstile
B.Turnstiles are associated with kernel threads, not objects βœ…
C.Turnstiles are shared globally across all locks
D.Turnstiles are allocated only for reader-writer locks
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Since a thread can block on only one object at a time, associating turnstiles with threads is more efficient than assigning one to every synchronized object, reducing memory overhead.

Q8. What happens to the turnstile when the first thread blocks on a synchronized object?

A.It is deleted immediately
B.It becomes the turnstile for that object βœ…
C.It is returned to the free list
D.It is merged with the global queue
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The turnstile belonging to the first blocking thread is repurposed to serve as the queue for the synchronized object itself, optimizing resource usage.

Q9. Which protocol do Solaris turnstiles use to prevent priority inversion?

A.Priority Ceiling Protocol
B.Priority Inheritance Protocol βœ…
C.Round-Robin Scheduling
D.First-Come-First-Served
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Turnstiles organize threads using a priority inheritance protocol, where a lower-priority lock holder temporarily inherits the priority of a higher-priority blocked thread.

Q10. What is a key difference between kernel-level and user-level locking mechanisms in Solaris regarding priority?

A.User-level locks use priority inheritance; kernel locks do not
B.Kernel locks use priority inheritance; user-level locks do not βœ…
C.Both use identical priority handling
D.User-level locks disable interrupts
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Kernel locking routines adhere to the kernel’s priority inheritance methods to prevent inversion. User-level thread-locking mechanisms do not provide this functionality, making them susceptible to inversion.

Q11. If a thread holding an adaptive mutex is currently running on another CPU, what action does the waiting thread take?

A.It blocks and goes to sleep
B.It spins while waiting for the lock βœ…
C.It yields its time slice permanently
D.It raises its own priority
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Spinning is chosen because the lock holder is active and likely to release the lock soon, making the wait time shorter than the cost of a context switch.

Q12. When is it more efficient to use condition variables and semaphores instead of adaptive mutexes?

A.For code segments executing fewer than 10 instructions
B.For code segments where the lock is held for a long duration βœ…
C.For single-processor systems only
D.For read-only data access
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: For long code segments, the cost of spinning (wasting CPU cycles) exceeds the cost of context switching. Semaphores and condition variables allow the thread to sleep, freeing the CPU.

Q13. What triggers a waiting thread to wake up when using semaphores or condition variables in Solaris?

A.A timeout event
B.A signal issued by the thread releasing the lock βœ…
C.A hardware interrupt
D.A change in CPU priority
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: When a thread frees a lock protected by these mechanisms, it issues a signal to the next sleeping thread in the queue, waking it up to proceed.

Q14. Why is spin-waiting considered exceedingly inefficient for long code segments?

A.It causes memory leaks
B.It wastes several hundred instructions while waiting βœ…
C.It prevents other threads from reading data
D.It requires hardware support not present in all CPUs
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Spinning consumes CPU cycles without doing useful work. If the hold time is long, this waste is significant compared to the fixed cost of putting a thread to sleep and waking it later.

Q15. In Solaris, what determines if a thread will spin or sleep when encountering a locked adaptive mutex on a multiprocessor system?

A.The size of the critical section
B.The state of the thread holding the lock βœ…
C.The type of data being accessed
D.The number of available cores
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The decision is dynamic: if the holder is running, the waiter spins; if the holder is sleeping, the waiter sleeps. This adaptivity optimizes performance based on real-time conditions.

Q16. Which of the following best describes the role of turnstiles in Solaris?

A.To execute critical sections
B.To order threads waiting to acquire a lock βœ…
C.To manage memory allocation
D.To schedule CPU time slices
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Turnstiles act as queues to organize and prioritize threads that are blocked while waiting for a specific lock to become available.

Q17. What happens to a lower-priority thread holding a lock when a higher-priority thread blocks on it?

A.It is terminated
B.It continues at its original priority
C.It temporarily inherits the higher priority βœ…
D.It is moved to the back of the queue
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: This is the priority inheritance protocol. The lower-priority thread boosts its priority to ensure it runs sooner and releases the lock, preventing the high-priority thread from being starved.

Q18. Why does Solaris give each kernel thread its own turnstile instead of each object?

A.Threads block on multiple objects simultaneously
B.A thread blocks on only one object at a time βœ…
C.Objects do not require queuing
D.It simplifies hardware design
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: This design choice leverages the fact that a thread can only wait on one lock at a time, making thread-associated turnstiles more memory-efficient than object-associated ones.

Q19. Which synchronization primitive is most suitable for protecting data that is rarely modified but frequently read?

A.Adaptive Mutex
B.Semaphore
C.Reader-Writer Lock βœ…
D.Spinlock
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Reader-writer locks allow multiple concurrent readers, maximizing throughput for read-heavy scenarios, whereas mutexes and semaphores would serialize access unnecessarily.

Q20. What is the consequence of using an adaptive mutex for a very long critical section?

A.Increased concurrency
B.Excessive CPU waste due to spinning βœ…
C.Automatic conversion to a semaphore
D.Priority inversion prevention
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Adaptive mutexes may spin. If the section is long, spinning wastes significant CPU resources. Solaris recommends semaphores or condition variables for long sections to allow sleeping.

Q21. In a single-processor Solaris system, why is spinning never used for adaptive mutexes?

A.The hardware does not support atomic operations
B.The lock holder cannot be running if another thread is testing the lock βœ…
C.Spinning causes data corruption
D.Single processors use only semaphores
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Since only one thread executes at a time, if a thread is checking a lock, the owner must be suspended. Spinning would just waste cycles until the scheduler switches back, so sleeping is mandatory.

Q22. What occurs when a thread releases a lock associated with a turnstile?

A.The turnstile is destroyed
B.The kernel selects the next thread from the turnstile βœ…
C.All waiting threads are woken up
D.The priority is reset to zero
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The kernel uses the turnstile queue to select the next appropriate thread (based on priority/protocol) to acquire the lock, ensuring orderly access.

Q23. Which statement accurately reflects the implementation cost of reader-writer locks in Solaris?

A.They are cheaper than semaphores
B.They are relatively expensive to implement βœ…
C.They have zero overhead
D.They are hardware-implemented
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Due to their complexity in managing multiple readers and exclusive writers, reader-writer locks have higher implementation costs, limiting their use to longer critical sections.

Q24. How does Solaris handle the turnstile of the initial blocking thread after the lock is released?

A.It is kept with the object permanently
B.It is returned to a list of free turnstiles βœ…
C.It is assigned to the next waiting thread
D.It is deleted from memory
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Once the lock is released and the turnstile is no longer needed for that specific object instance, the initial thread’s turnstile is reclaimed and returned to a kernel-maintained free list.

Q25. What is the primary reason for fine-tuning locking methods in the Solaris kernel?

A.To reduce code size
B.To produce great performance gains in crucial functions βœ…
C.To simplify debugging
D.To support legacy hardware
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Locks are used frequently in kernel functions. Optimizing their implementation reduces overhead and contention, leading to significant overall system performance improvements.

Q26. If a thread encounters a locked adaptive mutex and the holder is sleeping, what is the waiting thread's state?

A.Running
B.Spinning
C.Blocked/Sleeping βœ…
D.Zombie
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: The waiting thread blocks (goes to sleep) because the lock holder is not running, meaning the lock will not be freed soon. Spinning would waste CPU cycles.

Q27. Which mechanism ensures that a high-priority thread is not indefinitely delayed by a low-priority thread holding a lock?

A.Spinlock
B.Priority Inheritance βœ…
C.Round-Robin
D.Time Slicing
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Priority inheritance temporarily boosts the low-priority thread's priority, allowing it to preempt other tasks and release the lock faster, thus unblocking the high-priority thread.

Q28. Why are semaphores preferred over adaptive mutexes for long critical sections?

A.Semaphores always spin
B.Semaphores allow threads to sleep, saving CPU βœ…
C.Semaphores are faster for short codes
D.Semaphores do not require locks
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Semaphores put waiting threads to sleep. For long holds, this avoids the massive CPU waste associated with spinning, making the context switch cost worthwhile.

Q29. What is the relationship between turnstiles and synchronized objects in Solaris?

A.One turnstile per object always
B.Turnstiles are dynamically associated via blocking threads βœ…
C.Objects contain embedded turnstiles
D.Turnstiles are global
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Turnstiles are not statically bound to objects. They are associated dynamically when the first thread blocks, using that thread's turnstile as the object's queue.

Q30. Which of the following is NOT a feature of user-level thread locking in Solaris?

A.Mutual exclusion
B.Blocking capability
C.Priority inheritance βœ…
D.Signaling
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: User-level locking mechanisms in Solaris do not implement priority inheritance, unlike kernel-level routines. This makes them simpler but vulnerable to priority inversion.

Q31. An adaptive mutex starts as what type of lock on a multiprocessor system?

A.A reader-writer lock
B.A standard semaphore implemented as a spinlock βœ…
C.A condition variable
D.A binary semaphore
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Initially, it acts as a spinlock (semaphore-based). It adapts its behavior (spinning vs. sleeping) based on the state of the lock holder.

Q32. What is the threshold for considering a code segment 'short' for adaptive mutex usage?

A.Less than 10 instructions
B.Less than a few hundred instructions βœ…
C.Less than 1 millisecond
D.Less than 10 microseconds
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Solaris defines short segments as those where the lock is held for less than a few hundred instructions, making spin-waiting acceptable.

Q33. If multiple threads are waiting on a reader-writer lock, how does the turnstile help?

A.It allows all to read simultaneously
B.It orders the waiting threads βœ…
C.It converts them to writers
D.It deletes redundant threads
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The turnstile queues the blocked threads, allowing the kernel to select the next owner efficiently when the lock is released, respecting priority protocols.

Q34. Why is the adaptive mutex called 'adaptive'?

A.It changes its size
B.It adapts between spinning and sleeping based on context βœ…
C.It works on any OS
D.It adapts to user preferences
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: It adapts its waiting strategy: spinning if the holder is running (fast release expected) and sleeping if the holder is blocked (slow release expected).

Q35. What happens to the priority of a thread after it releases a lock acquired under priority inheritance?

A.It remains elevated
B.It reverts to its original priority βœ…
C.It drops to the lowest level
D.It is assigned randomly
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Once the lock is released, the temporary priority boost is removed, and the thread returns to its normal, original scheduling priority.

Q36. Which scenario best justifies the use of a reader-writer lock?

A.A database record updated every second
B.A configuration file read by 100 threads, written by 1 βœ…
C.A counter incremented by all threads
D.A hardware register access
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: High read frequency with rare writes is the ideal use case. Reader-writer locks allow the 100 readers to proceed concurrently, unlike mutexes which would force serial access.

Q37. In Solaris, what is the role of the 'free list' of turnstiles?

A.To store unused locks
B.To provide available turnstiles for new blocking events βœ…
C.To track completed threads
D.To manage memory fragmentation
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The kernel maintains a list of free turnstiles. When a thread needs to block and doesn't have an active turnstile association, or when one is released, this list manages availability.

Q38. Why is context switching considered 'extra cost' in synchronization?

A.It requires hardware replacement
B.It involves saving/restoring state and flushing caches βœ…
C.It deletes data
D.It resets the CPU
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Putting a thread to sleep and waking it involves saving registers, updating PCBs, and potential cache misses. This overhead is only justified if the wait time is long.

Q39. What is the behavior of an adaptive mutex on a multiprocessor system if the lock holder is pre-empted?

A.The waiter spins
B.The waiter sleeps βœ…
C.The waiter crashes
D.The waiter becomes the owner
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: If the holder is pre-empted (not running), it is treated as a sleeping thread. The waiter sleeps to avoid spinning on a lock that won't be released until the holder is rescheduled.

Q40. Which component is responsible for selecting the next thread from a turnstile?

A.The user application
B.The kernel βœ…
C.The hardware timer
D.The thread itself
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: The kernel manages the turnstile queue and selects the next thread to acquire the lock based on the scheduling policy and priority inheritance rules.

Q41. What is the main disadvantage of using semaphores for very short critical sections?

A.They do not provide mutual exclusion
B.The overhead of sleep/wake exceeds spin cost βœ…
C.They cause deadlocks
D.They are not supported in Solaris
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: For very short waits, the fixed cost of context switching (sleep/wake) is higher than simply spinning for a few cycles. Hence, mutexes are preferred for short sections.

Q42. How does Solaris ensure that turnstiles do not consume excessive memory?

A.By limiting the number of threads
B.By associating them with threads rather than objects βœ…
C.By using compressed data structures
D.By deleting them after every use
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Associating turnstiles with threads (which block on one object at a time) is more scalable than assigning a turnstile to every synchronized object in the system.

Q43. What is the result of priority inversion if not handled by inheritance?

A.System crash
B.High-priority thread blocked by low-priority thread βœ…
C.Data corruption
D.Memory leak
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Without inheritance, a low-priority thread holding a lock can be preempted by medium-priority threads, indefinitely blocking a high-priority thread waiting for the same lock.

Q44. Which lock type is used to protect every critical data item in Solaris by default?

A.Reader-Writer Lock
B.Semaphore
C.Adaptive Mutex βœ…
D.Condition Variable
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Adaptive mutexes are the fundamental building block for protecting critical data items, especially for short accesses.

Q45. When a thread signals a condition variable, what happens to the waiting thread?

A.It terminates
B.It moves from sleep to ready/runnable βœ…
C.It spins
D.It loses priority
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The signal wakes the sleeping thread, moving it to the ready queue so it can compete for the CPU and reacquire the necessary resources.

Q46. Why are reader-writer locks not used for short code segments?

A.They do not support short codes
B.Their implementation cost outweighs benefits for short durations βœ…
C.They cause spinning
D.They are incompatible with mutexes
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The overhead of setting up and managing reader-writer logic is high. For short segments, a simple mutex is faster and more efficient.

Q47. What is the state of a thread in a turnstile?

A.Running
B.Ready
C.Blocked βœ…
D.Terminated
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Threads in a turnstile are blocked, waiting for a lock to be released. They are not eligible for CPU execution until they acquire the lock.

Q48. How does Solaris handle a situation where a high-priority thread blocks on a lock held by a low-priority thread?

A.It aborts the low-priority thread
B.It uses priority inheritance βœ…
C.It ignores the priority
D.It swaps the threads
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Priority inheritance is used. The low-priority thread inherits the high priority, ensuring it runs quickly to release the lock.

Q49. Which of the following is true about Solaris user-level locks?

A.They support priority inheritance
B.They are identical to kernel locks
C.They do not support priority inheritance βœ…
D.They are hardware-based
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: A crucial distinction is that user-level locking mechanisms in Solaris lack the priority inheritance protocol found in kernel routines.

Q50. What is the primary benefit of the adaptive nature of mutexes?

A.Simplicity
B.Optimized performance across different wait scenarios βœ…
C.Lower memory usage
D.Hardware independence
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: By adapting between spinning and sleeping, it minimizes CPU waste for long waits and minimizes latency for short waits, optimizing overall performance.

Q51. In Solaris, what happens if a thread tries to acquire a lock that is already held by a thread on the same CPU in a single-processor system?

A.It spins
B.It sleeps βœ…
C.It fails
D.It preempts the holder
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: On a single processor, the holder cannot be running if the waiter is trying to acquire. Thus, the holder must be suspended, so the waiter must sleep to yield the CPU.

πŸ”— Related Topics (MCQs)