🎓 BookMCQ
← Back to 5. Process Synchronization

📝 Process synchronization in Windows (65 MCQs)

📖 From Operating System • 5. Process Synchronization • 65 questions available

What is Process synchronization in Windows?

Definition:
Windows process synchronization provides kernel objects like mutexes, semaphores, events, and critical sections accessible via Win32 API for user-mode and kernel-mode coordination.

Example:
Calling WaitForSingleObject(hMutex,INFINITE)WaitForSingleObject(hMutex, INFINITE) blocks the thread until the mutex object is signaled, with timeout support dwMillisecondsdwMilliseconds.

Reason:
Windows integrates synchronization with its object manager and security model, enabling cross-process synchronization and supporting both lightweight user-mode critical sections and heavyweight kernel objects.

20
Easy
30
Medium
15
Hard

📝 All Process synchronization in Windows MCQs

Q1. What mechanism does the Windows kernel use to protect global resources on a single-processor system?

A.Spinlocks
B.Interrupt masking ✅
C.Dispatcher objects
D.Critical sections
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The Windows kernel temporarily masks interrupts on single-processor systems to protect global resources. This prevents interrupt handlers that might access the same resource from interrupting the current thread. Spinlocks are used specifically on multiprocessor systems, not single-processor systems.

Q2. Which synchronization mechanism does Windows use exclusively for multiprocessor systems to protect global resources?

A.Interrupt masking
B.Mutex locks
C.Spinlocks ✅
D.Critical-section objects
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Windows uses spinlocks on multiprocessor systems to protect access to global resources. Unlike interrupt masking which works on single-processor systems, spinlocks are designed for multiprocessor environments where multiple threads can execute simultaneously on different processors.

Q3. What type of objects does Windows provide for thread synchronization outside the kernel?

A.Kernel objects
B.Dispatcher objects ✅
C.Spinlock objects
D.Interrupt objects
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Windows provides dispatcher objects for thread synchronization outside the kernel. These include mutex locks, semaphores, events, and timers. Dispatcher objects manage thread synchronization through signaled and nonsignaled states, controlling whether threads block or continue execution.

Q4. Which dispatcher object in Windows is equivalent to condition variables?

A.Mutex locks
B.Semaphores
C.Events ✅
D.Timers
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Events in Windows are similar to condition variables in that they notify waiting threads when a desired condition occurs. While mutex locks provide mutual exclusion and semaphores control resource access, events specifically signal condition changes to waiting threads, making them analogous to condition variables.

Q5. What does it mean when a dispatcher object is in a signaled state?

A.The object is unavailable and threads block
B.The object is available and threads do not block ✅
C.The object has been destroyed
D.The object is in a waiting state
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A dispatcher object in a signaled state is available for acquisition by threads. Threads attempting to acquire such an object will not block and can proceed with execution. This state indicates that the resource or condition represented by the object is ready for use.

Q6. What happens when a thread blocks on a nonsignaled dispatcher object?

A.The thread continues execution
B.The thread is terminated
C.The thread changes from ready to waiting state ✅
D.The thread changes from waiting to ready state
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: When a thread blocks on a nonsignaled dispatcher object, it transitions from the ready state to the waiting state. The thread is then placed in a waiting queue for that specific object until the object transitions to a signaled state, at which point the thread may be moved back to the ready state.

Q7. How many threads does the kernel select from the waiting queue for a mutex object when it becomes signaled?

A.All waiting threads
B.One thread ✅
C.Two threads
D.Half of the waiting threads
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The kernel selects only one thread from the waiting queue for a mutex object because a mutex can be owned by only a single thread at a time. This ensures mutual exclusion - only one thread acquires the mutex lock when it becomes available, maintaining the exclusive ownership property of mutexes.

Q8. How many threads does the kernel select from the waiting queue for an event object when it becomes signaled?

A.One thread
B.Two threads
C.All waiting threads ✅
D.Half of the waiting threads
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The kernel selects all threads waiting for an event object when it becomes signaled. Unlike mutex locks which only allow single ownership, events are designed to notify all waiting threads simultaneously when a condition occurs, making them suitable for broadcast-style synchronization scenarios.

Q9. What is a critical-section object in Windows?

A.A kernel-mode spinlock
B.A user-mode mutex ✅
C.A dispatcher object
D.An interrupt handler
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A critical-section object in Windows is a user-mode mutex that provides efficient synchronization without kernel intervention in most cases. It uses spinlocks initially and only allocates a kernel mutex when there is contention, making it particularly efficient for scenarios where contention is low.

Q10. When does a critical-section object allocate a kernel mutex?

A.Immediately upon creation
B.Never, it only uses spinlocks
C.When it spins too long waiting for the object ✅
D.When a thread first attempts to acquire it
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A critical-section object allocates a kernel mutex only when it spins too long waiting for another thread to release the object. This two-tier approach makes critical-section objects efficient because kernel mutex allocation is expensive and only occurs when there is actual contention, which is rare in practice.

Q11. Why are critical-section objects particularly efficient in Windows?

A.They always use kernel mutexes
B.They allocate kernel mutex only on contention ✅
C.They use only spinlocks
D.They never block threads
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Critical-section objects are efficient because the kernel mutex is allocated only when there is contention for the object. Since contention is typically low in practice, most acquisitions occur without kernel intervention, avoiding the overhead of kernel-mode transitions and mutex allocation.

Q12. What is the primary purpose of spinlocks in the Windows kernel?

A.To protect long code segments
B.To protect short code segments ✅
C.To synchronize user-mode threads
D.To handle interrupt masking
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The Windows kernel uses spinlocks specifically to protect short code segments. Using spinlocks for long code segments would be inefficient as waiting threads would waste CPU cycles spinning. This design choice balances efficiency with the need for multiprocessor synchronization in kernel-mode code.

Q13. What is the relationship between thread states and dispatcher objects in Windows?

A.There is no relationship
B.Thread state depends only on CPU availability
C.Threads block on nonsignaled objects and wait ✅
D.Threads always run regardless of object state
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When a thread blocks on a nonsignaled dispatcher object, its state changes from ready to waiting and it is placed in a waiting queue for that object. When the object becomes signaled, the kernel moves one or more threads from the waiting state to the ready state, where they can resume execution.

Q14. Which statement accurately describes mutex lock behavior with dispatcher objects?

A.Mutex lock is always in signaled state
B.Mutex lock can be owned by multiple threads
C.Mutex lock moves to nonsignaled when acquired ✅
D.Mutex lock selects all waiting threads when signaled
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A mutex lock dispatcher object is in a nonsignaled state when acquired by a thread, preventing other threads from acquiring it. When the owning thread releases the lock, the mutex transitions to the signaled state, allowing one waiting thread to acquire it and move the mutex back to nonsignaled state.

Q15. What happens to a thread that attempts to acquire a nonsignaled mutex dispatcher object?

A.The thread is immediately terminated
B.The thread continues execution
C.The thread is suspended and placed in waiting queue ✅
D.The thread is moved to the ready state
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When a thread attempts to acquire a mutex dispatcher object that is in a nonsignaled state, the thread is suspended and placed in a waiting queue for that mutex object. The thread will remain in the waiting state until the mutex becomes signaled, at which point the first thread in the queue will be moved to the ready state.

Q16. Which kernel action occurs when a dispatcher object transitions to the signaled state?

A.The object is destroyed
B.The object moves to nonsignaled state
C.The kernel checks for waiting threads ✅
D.The kernel terminates waiting threads
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When a dispatcher object moves to the signaled state, the kernel checks whether any threads are waiting on that object. If waiting threads exist, the kernel selects one or more threads (depending on the object type) from the waiting queue and moves them from the waiting state to the ready state, allowing them to resume execution.

Q17. Why does Windows ensure that a thread holding a spinlock is never preempted?

A.To prevent deadlocks ✅
B.To maximize CPU utilization
C.To minimize kernel overhead
D.To avoid priority inversion
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Windows ensures that a thread holding a spinlock is never preempted to prevent deadlocks and other synchronization issues. If a thread holding a spinlock were preempted, other processors might spin waiting for it to release the lock, wasting CPU cycles and potentially causing system-wide performance degradation.

Q18. What type of synchronization mechanism would a Windows developer use to protect shared data with mutual exclusion?

A.Events
B.Timers
C.Mutex locks ✅
D.Semaphores
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Windows developers use mutex locks to protect shared data by requiring threads to gain ownership of the mutex before accessing the data and release ownership when finished. Mutex locks ensure mutual exclusion, preventing multiple threads from simultaneously accessing critical sections of code that manipulate shared data.

Q19. How do semaphores behave in the Windows dispatcher object model?

A.They allow only one thread to pass
B.They allow a specified number of threads to pass ✅
C.They notify all waiting threads
D.They do not block threads
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Semaphores in Windows behave as described in classical synchronization theory - they allow a specified number of threads to pass through the critical section simultaneously. The semaphore maintains a count that controls access, decrementing when a thread acquires it and incrementing when a thread releases it.

Q20. What happens when a mutex moves to the signaled state in Windows?

A.All waiting threads are moved to ready state
B.The first thread in the waiting queue moves to ready state ✅
C.The mutex is destroyed
D.The waiting queue is cleared
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a mutex moves to the signaled state because another thread has released the lock, the thread waiting at the front of the queue is moved from the waiting state to the ready state. This thread then acquires the mutex lock, moving the mutex back to the nonsignaled state.

Q21. What is the primary use of timers as dispatcher objects in Windows?

A.To protect shared data
B.To control access to resources
C.To notify threads of time expiration ✅
D.To synchronize multiple processors
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Timers in Windows are used to notify one or more threads that a specified amount of time has expired. This is useful for timeout scenarios, periodic operations, and scheduling tasks. When a timer expires, it transitions to a signaled state, notifying waiting threads that the time condition has been met.

Q22. Which mechanism would be most efficient for protecting a short critical section in a user-mode application on a multiprocessor system?

A.Kernel mutex
B.Interrupt masking
C.Critical-section object ✅
D.Dispatcher event
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A critical-section object would be most efficient for protecting a short critical section in a user-mode application on a multiprocessor system. It uses spinlocks initially and only allocates kernel mutexes when there is contention, avoiding the overhead of kernel transitions while still providing proper synchronization on multiprocessor systems.

Q23. What is the fundamental difference between how mutex and event dispatcher objects handle waiting threads when signaled?

A.Mutex selects one thread, event selects all threads ✅
B.Mutex selects all threads, event selects one thread
C.Both select all threads
D.Both select one thread
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The fundamental difference is that mutex selects only one thread from the waiting queue when signaled, while event selects all waiting threads. This reflects their different purposes: mutex ensures exclusive ownership by a single thread, while event broadcasts a condition change to all waiting threads simultaneously.

Q24. In the Windows synchronization model, what state transition occurs when a thread acquires a mutex lock?

A.The mutex moves from signaled to nonsignaled ✅
B.The mutex moves from nonsignaled to signaled
C.The thread moves from waiting to ready
D.The thread moves from ready to waiting
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When a thread acquires a mutex lock, the mutex object transitions from the signaled state (available) to the nonsignaled state (unavailable). This prevents other threads from acquiring the mutex while the current thread holds it, ensuring exclusive ownership. The mutex remains nonsignaled until the owning thread releases it.

Q25. What is the significance of the two-tier locking approach used by critical-section objects?

A.It eliminates all synchronization overhead
B.It provides optimal performance by using kernel mutex only during contention ✅
C.It ensures all threads wait equally
D.It prevents all deadlocks
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The two-tier approach used by critical-section objects is significant because it provides optimal performance - spinlocks handle the common case where contention is low, while kernel mutexes are only allocated when contention occurs. This design minimizes overhead by avoiding kernel transitions in the most common scenario, while still providing proper synchronization when needed.

Q26. What makes Windows a multithreaded kernel?

A.It runs only single-threaded processes
B.It supports real-time applications and multiple processors ✅
C.It does not support thread synchronization
D.It only uses interrupt masking
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Windows is a multithreaded kernel that provides support for real-time applications and multiple processors. This means the kernel itself can execute multiple threads concurrently, requiring sophisticated synchronization mechanisms to protect global resources and ensure correct operation in multiprocessor environments.

Q27. How does the Windows kernel protect global resources on a multiprocessor system?

A.By masking interrupts
B.By using spinlocks ✅
C.By using events only
D.By using semaphores only
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The Windows kernel protects global resources on multiprocessor systems by using spinlocks. Unlike single-processor systems where interrupt masking is sufficient, multiprocessor systems require spinlocks to synchronize access to shared resources across multiple processors that may be executing simultaneously.

Q28. What is the primary characteristic of a spinlock in Windows?

A.It causes threads to block and yield CPU
B.It causes threads to wait while repeatedly checking ✅
C.It always allocates kernel objects
D.It uses interrupt masking
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A spinlock causes threads to wait by repeatedly checking the lock condition in a tight loop (spinning) until the lock becomes available. This is efficient for short code segments because it avoids context switching overhead, but consumes CPU cycles while waiting. The kernel ensures threads holding spinlocks are not preempted to prevent performance degradation.

Q29. What type of synchronization object would be most appropriate for a scenario where multiple threads need to be notified when a condition occurs?

A.Mutex lock
B.Semaphore
C.Event ✅
D.Timer
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: An event would be most appropriate when multiple threads need to be notified when a condition occurs. Events are designed specifically for this purpose - they notify waiting threads when a desired condition occurs, and can signal all waiting threads simultaneously, making them ideal for broadcast-style notifications.

Q30. Which statement best describes the relationship between Windows dispatcher objects and thread waiting queues?

A.Each dispatcher object has one waiting queue
B.Threads can only wait on one object at a time
C.The kernel moves waiting threads to ready state when object signals ✅
D.All threads waiting on an object are moved to ready state simultaneously
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: When a dispatcher object transitions to the signaled state, the kernel checks if any threads are waiting on that object. It then selects one or more threads from the waiting queue and moves them to the ready state. The number of threads moved depends on the object type - mutex moves one thread, while events move all waiting threads.

Q31. How does Windows prevent a thread from being preempted while holding a spinlock?

A.By disabling interrupts entirely
B.By ensuring the thread maintains a higher priority
C.By design not to preempt threads with spinlocks ✅
D.By using kernel mutexes instead
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Windows ensures that a thread holding a spinlock will never be preempted, as this design prevents deadlocks and performance issues. If a thread holding a spinlock were preempted, other processors might spin indefinitely waiting for the lock to be released, wasting CPU cycles and potentially causing system-wide degradation.

Q32. What happens to the waiting queue for a mutex when the owning thread releases the lock?

A.The mutex becomes signaled and one waiting thread moves to ready ✅
B.The mutex becomes signaled and all waiting threads move to ready
C.The mutex remains nonsignaled and threads stay waiting
D.The waiting queue is destroyed
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When the owning thread releases a mutex lock, the mutex becomes signaled and the thread at the front of the waiting queue is moved to the ready state. This selected thread will then acquire the mutex, transitioning it back to the nonsignaled state. Only one thread is selected because mutexes enforce exclusive ownership.

Q33. What advantage do critical-section objects offer over direct kernel mutex usage in Windows?

A.They always use less memory
B.They avoid kernel transitions except on contention ✅
C.They work on all Windows versions
D.They support all processor architectures
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Critical-section objects offer the advantage of avoiding kernel transitions except when there is contention. In the common case where there is no contention, the critical-section object can be acquired and released entirely in user mode, providing significantly better performance than direct kernel mutex usage which always requires a kernel transition.

Q34. How does Windows handle synchronization for threads using events?

A.Only one thread can wait on an event
B.All threads waiting on an event are moved to ready state when signaled ✅
C.Events do not use waiting queues
D.Events cause threads to terminate
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When an event object becomes signaled, the kernel selects all threads that are waiting for that event and moves them from the waiting state to the ready state. This behavior distinguishes events from mutexes and makes them suitable for scenarios where multiple threads need to be notified of a condition simultaneously.

Q35. What is the purpose of the nonsignaled state for a dispatcher object?

A.To indicate the object is available
B.To indicate the object is unavailable ✅
C.To destroy the object
D.To create the object
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A dispatcher object in a nonsignaled state is unavailable for threads to acquire. Threads attempting to acquire an object in this state will block and be placed in the object's waiting queue until the object transitions to the signaled state, indicating availability.

Q36. What synchronization mechanism would be most suitable for managing access to a resource pool with limited capacity?

A.Mutex lock
B.Event
C.Semaphore ✅
D.Timer
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A semaphore would be most suitable for managing access to a resource pool with limited capacity. Semaphores maintain a count that represents available resources, allowing up to a specified number of threads to acquire access simultaneously. This makes them ideal for managing finite resource pools like database connections or thread pools.

Q37. What is the main reason Windows uses spinlocks only for short code segments?

A.To conserve memory
B.To avoid excessive CPU consumption ✅
C.To prevent interrupt masking
D.To simplify the kernel design
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Windows uses spinlocks only for short code segments to avoid excessive CPU consumption. When threads spin waiting for a lock, they consume CPU cycles without making progress. For short code segments, the spinning time is limited and acceptable. For longer code segments, the CPU waste would be excessive, making other synchronization mechanisms more appropriate.

Q38. How does the Windows kernel determine which threads to move from waiting to ready when a dispatcher object signals?

A.It moves all waiting threads regardless of type
B.It moves one thread for mutex and all threads for events ✅
C.It moves threads based on priority only
D.It moves threads in random order
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The Windows kernel determines the number of threads to move based on the type of dispatcher object. For a mutex, which can be owned by only one thread, exactly one thread is moved from the waiting queue to the ready state. For an event, all waiting threads are moved to the ready state simultaneously. This behavior reflects the different synchronization semantics of these objects.

Q39. What state changes occur when a thread waiting on a mutex is selected to acquire the lock?

A.The thread moves from waiting to ready and mutex becomes nonsignaled ✅
B.The thread moves from waiting to running and mutex becomes signaled
C.The thread stays waiting and mutex becomes signaled
D.The thread terminates and mutex becomes nonsignaled
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When a thread waiting on a mutex is selected to acquire the lock, the thread moves from the waiting state to the ready state, where it can resume execution. Simultaneously, the mutex transitions to the nonsignaled state, indicating it is now owned and unavailable to other threads. This ensures mutual exclusion is maintained during critical section execution.

Q40. Which scenario demonstrates the most efficient use of Windows synchronization mechanisms?

A.Using kernel mutex for all synchronization
B.Using critical-section objects for short user-mode critical sections ✅
C.Using spinlocks for long code segments
D.Using events for mutual exclusion
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Using critical-section objects for short user-mode critical sections demonstrates the most efficient use of Windows synchronization mechanisms. Critical-section objects avoid kernel transitions in the common case (no contention), using spinlocks and only allocating kernel mutexes when contention occurs. This provides optimal performance while maintaining proper synchronization.

Q41. What mechanism does the Windows kernel use to protect global resources accessed by interrupt handlers?

A.It uses spinlocks exclusively
B.It temporarily masks interrupts ✅
C.It uses critical-section objects
D.It uses event objects
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The Windows kernel temporarily masks interrupts for all interrupt handlers that may also access the global resource. This ensures that interrupt handlers cannot preempt the current thread while it holds the resource, preventing race conditions. This approach works on single-processor systems where only one thread can execute at a time.

Q42. How does the behavior of a mutex differ from an event when multiple threads are waiting?

A.Both move exactly one thread to ready
B.Mutex moves one thread, event moves all waiting threads ✅
C.Event moves one thread, mutex moves all waiting threads
D.Both move all waiting threads to ready
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A mutex moves exactly one waiting thread to the ready state when it becomes signaled, while an event moves all waiting threads to the ready state. This reflects their different synchronization purposes: mutexes enforce exclusive ownership, while events broadcast condition changes to all waiting threads simultaneously.

Q43. What is the relationship between the state of a dispatcher object and the state of a thread in Windows?

A.No relationship exists
B.Thread state is independent of dispatcher object state
C.Threads in waiting state are associated with nonsignaled dispatcher objects ✅
D.Threads always run regardless of object state
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Threads in the waiting state are associated with nonsignaled dispatcher objects. When a thread blocks on a nonsignaled dispatcher object, it changes from ready to waiting state and is placed in the object's waiting queue. When the object transitions to signaled state, waiting threads are moved back to the ready state.

Q44. Which Windows synchronization object would be most appropriate for implementing a producer-consumer pattern?

A.Mutex lock
B.Semaphore ✅
C.Event
D.Timer
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A semaphore would be most appropriate for implementing a producer-consumer pattern. Semaphores can track the count of available items in a buffer, allowing consumers to block when the buffer is empty and producers to block when the buffer is full. The semaphore's counting capability makes it ideal for managing shared buffers in producer-consumer scenarios.

Q45. What is the advantage of using critical-section objects over spinlocks in user-mode applications?

A.Critical-section objects work on all processor types
B.Critical-section objects allow the thread to yield CPU during long waits ✅
C.Critical-section objects are faster in all cases
D.Critical-section objects prevent all deadlocks
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Critical-section objects have the advantage of allowing threads to yield the CPU when waiting for extended periods. After spinning for a while without acquiring the object, the thread allocates a kernel mutex and yields the CPU. This prevents CPU waste during long waits, unlike spinlocks which continue consuming CPU cycles until the lock is acquired.

Q46. How does Windows implement the signaling mechanism for dispatcher objects?

A.Signaling is handled by the thread scheduler
B.Signaling is handled by the kernel's interrupt handler
C.Signaling transitions object state and may move waiting threads ✅
D.Signaling destroys the object
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The signaling mechanism for dispatcher objects involves transitioning the object to the signaled state, which may then cause the kernel to move waiting threads to the ready state. The kernel handles this process, checking waiting queues and moving threads based on the object type. This mechanism allows threads to synchronize their execution based on object states.

Q47. What is the primary purpose of the waiting queue associated with a dispatcher object?

A.To store objects for later use
B.To manage threads blocked on the object ✅
C.To track object ownership
D.To maintain object state history
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The waiting queue associated with a dispatcher object stores threads that are blocked (in waiting state) because the object is in a nonsignaled state. When the object becomes signaled, the kernel uses this queue to determine which threads to move to the ready state. The queue ensures fair and orderly access to synchronization objects.

Q48. Which synchronization mechanism would be most efficient for a scenario where contention is expected to be very low?

A.Kernel mutex
B.Spinlock
C.Critical-section object ✅
D.Event
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A critical-section object would be most efficient when contention is expected to be very low. It uses a spinlock initially and only allocates a kernel mutex if it spins too long. With low contention, most acquisitions succeed quickly without kernel intervention, providing excellent performance. If contention were higher, the kernel mutex allocation overhead would increase.

Q49. What is the significance of the thread selection behavior for mutex versus event dispatcher objects?

A.Both object types use the same selection behavior
B.Mutex selection ensures exclusive ownership while event provides broadcast notification ✅
C.Event selection ensures exclusive ownership while mutex provides broadcast
D.Selection behavior is user-configurable
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The difference in thread selection behavior between mutex and event dispatcher objects reflects their different synchronization semantics. Mutex selection of exactly one thread ensures exclusive ownership, maintaining the mutual exclusion property. Event selection of all waiting threads provides broadcast notification, allowing all waiting threads to respond simultaneously to a condition change.

Q50. How does Windows handle the situation when a thread tries to acquire a nonsignaled mutex?

A.The thread is allowed to acquire it
B.The thread is moved to waiting state ✅
C.The thread is terminated
D.The mutex automatically signals
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: When a thread tries to acquire a nonsignaled mutex, the thread is suspended and placed in a waiting queue for that mutex. The thread will remain in the waiting state until the mutex becomes signaled, at which point one waiting thread will be selected to acquire the mutex and move to the ready state.

Q51. What makes Windows dispatcher objects a flexible synchronization mechanism?

A.They only support mutex locks
B.They provide multiple synchronization patterns through different object types ✅
C.They are only used in kernel mode
D.They cannot be used across threads
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Windows dispatcher objects are flexible because they provide multiple synchronization patterns through different object types - mutex locks for exclusive access, semaphores for counting, events for condition notification, and timers for time-based synchronization. This variety allows developers to choose the most appropriate synchronization mechanism for their specific needs.

Q52. How does a critical-section object's approach to synchronization contribute to Windows performance?

A.It always uses kernel mutexes
B.It eliminates all waiting
C.It minimizes kernel-mode transitions ✅
D.It prevents all context switching
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: A critical-section object's approach minimizes kernel-mode transitions by using spinlocks first and allocating kernel mutexes only when there is contention. In the common case of low contention, the object is acquired and released entirely in user mode, avoiding expensive kernel transitions. This design significantly improves performance while maintaining proper synchronization.

Q53. What distinguishes timers from other dispatcher objects in Windows?

A.Timers cannot signal threads
B.Timers signal based on time expiration ✅
C.Timers are only used in kernel mode
D.Timers have no waiting queues
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Timers are distinguished from other dispatcher objects by signaling based on time expiration rather than resource availability or condition changes. When a timer expires, it transitions to a signaled state, notifying waiting threads that the specified time has elapsed. This makes timers suitable for timeout scenarios and periodic operations.

Q54. How does Windows ensure efficient synchronization on multiprocessor systems?

A.Using only interrupt masking
B.Combining spinlocks for short segments and dispatcher objects for general use ✅
C.Using only dispatcher objects
D.Using only critical-section objects
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Windows ensures efficient synchronization on multiprocessor systems by combining spinlocks for short code segments (where spinning overhead is acceptable) with dispatcher objects (mutexes, semaphores, events) for general synchronization. This approach provides efficiency for short critical sections while offering rich synchronization capabilities for more complex scenarios.

Q55. What would happen if the Windows kernel did not ensure that threads holding spinlocks are never preempted?

A.Performance would improve
B.Deadlocks and CPU waste would increase ✅
C.Memory usage would decrease
D.Thread scheduling would be more fair
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: If the Windows kernel did not ensure that threads holding spinlocks are never preempted, deadlocks and CPU waste would increase significantly. A preempted thread holding a spinlock would cause other processors to spin waiting for the lock indefinitely, wasting CPU cycles and potentially causing system-wide performance degradation and deadlocks.

Q56. Which Windows synchronization object is best suited for ensuring exactly one thread at a time accesses a critical resource?

A.Event
B.Semaphore
C.Mutex lock ✅
D.Timer
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A mutex lock is best suited for ensuring exactly one thread at a time accesses a critical resource. Mutexes provide exclusive ownership, requiring threads to acquire the mutex before accessing the protected resource and release it when finished. This ensures mutual exclusion, preventing concurrent access to the critical resource.

Q57. What role do dispatcher objects play in Windows thread synchronization?

A.They prevent all thread scheduling
B.They control thread access to resources and conditions ✅
C.They only work in single-processor systems
D.They replace the thread scheduler
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Dispatcher objects control thread access to resources and conditions in Windows. Through their signaled/nonsignaled states, they determine whether threads can proceed or must wait. Mutexes, semaphores, events, and timers each provide different synchronization semantics, collectively forming a comprehensive synchronization framework for Windows applications.

Q58. How does the Windows kernel handle a waiting queue when multiple threads are waiting on an event that becomes signaled?

A.It moves one thread to ready state
B.It moves all threads to ready state ✅
C.It moves threads based on priority
D.It clears the waiting queue
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When an event becomes signaled, the Windows kernel moves all threads waiting on that event to the ready state. This makes events suitable for broadcast-style notifications where multiple threads need to respond to a condition change. The threads will then compete to execute, with the scheduler determining their actual execution order.

Q59. What is the purpose of using spinlocks in conjunction with critical-section objects?

A.To eliminate all waiting
B.To provide fast acquisition in low-contention scenarios ✅
C.To force all threads to wait
D.To reduce memory usage
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Spinlocks are used in conjunction with critical-section objects to provide fast acquisition in low-contention scenarios. The critical-section object first uses a spinlock to try to acquire the object without kernel intervention. Only when the spinlock spins too long does the critical-section object fall back to allocating a kernel mutex and yielding the CPU. This provides optimal performance for typical low-contention scenarios.

Q60. What distinguishes a semaphore from other Windows dispatcher objects?

A.It can be owned by multiple threads simultaneously ✅
B.It has no waiting queue
C.It is only used in kernel mode
D.It does not transition between states
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A semaphore is distinguished from other Windows dispatcher objects by allowing multiple threads to acquire it simultaneously, up to its maximum count. Unlike mutexes which allow only one owner, or events which broadcast condition changes, semaphores maintain a count that represents available resources, controlling how many threads can access the protected resource concurrently.

Q61. How does Windows coordinate synchronization across multiple processors?

A.Through a global interrupt mask
B.Through processor-specific spinlocks and dispatcher objects ✅
C.Through network messages
D.Through shared memory only
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Windows coordinates synchronization across multiple processors through processor-specific spinlocks and dispatcher objects. The kernel uses spinlocks to protect access to global resources across processors, while dispatcher objects provide higher-level synchronization for threads running on different processors. This combination allows efficient cross-processor synchronization while maintaining system performance.

Q62. What makes dispatcher objects suitable for both single and multiprocessor systems?

A.They only work on single processors
B.They adapt to the processor count ✅
C.They use interrupt masking
D.They are hardware-specific
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Dispatcher objects are suitable for both single and multiprocessor systems because they adapt to the processor count. On single-processor systems, they can leverage interrupt masking for efficiency. On multiprocessor systems, they can use spinlocks when necessary. This flexibility allows the same synchronization model to work effectively across different system configurations.

Q63. What is the relationship between critical-section objects and kernel mutexes?

A.Critical-section objects always use kernel mutexes
B.Critical-section objects use kernel mutexes only during contention ✅
C.Kernel mutexes use critical-section objects
D.They are the same thing
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Critical-section objects use kernel mutexes only during contention. When no contention exists, the critical-section object operates entirely in user mode using spinlocks. When contention occurs and the spinlock spins too long, the critical-section object allocates a kernel mutex and yields the CPU. This relationship allows critical-section objects to provide performance benefits while maintaining proper synchronization.

Q64. Which synchronization scenario would be best addressed using a Windows timer object?

A.Protecting shared data
B.Managing multiple threads waiting for a timeout ✅
C.Controlling access to a resource pool
D.Broadcasting a condition change to all threads
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A Windows timer object would be best used for managing multiple threads waiting for a timeout. Timers notify threads when a specified amount of time has expired, making them ideal for timeout scenarios, periodic operations, and scheduled tasks. They can signal one or multiple threads when the timer expires, providing time-based synchronization.

Q65. How does the Windows kernel prevent race conditions when accessing global resources?

A.By always using spinlocks
B.By using appropriate synchronization based on processor configuration ✅
C.By disabling all interrupts
D.By running all threads sequentially
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The Windows kernel prevents race conditions by using appropriate synchronization based on processor configuration. On single-processor systems, it masks interrupts that might access the same resources. On multiprocessor systems, it uses spinlocks to protect global resources. This adaptive approach ensures race conditions are prevented efficiently across different system configurations.

🔗 Related Topics (MCQs)