🎓 BookMCQ
← Back to 5. Process Synchronization

📝 Resuming Processes within a Monitor in Process synchronization (38 MCQs)

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

What is Resuming Processes within a Monitor in Process synchronization?

Definition:
Resuming processes within a monitor defines the semantics of signal operations, determining whether the signaler or signalee continues immediately (Hoare vs. Mesa semantics) to avoid ambiguity.

Example:
Under Hoare semantics, signal(c)signal(c) transfers control directly to the waiting process which re-enters the monitor atomically; under Mesa, the signaler continues and the waiter competes later.

Reason:
The choice affects program correctness and efficiency; Hoare simplifies reasoning but adds overhead, while Mesa matches modern OS scheduling but requires rechecking conditions after wakeup.

10
Easy
19
Medium
9
Hard

📝 All Resuming Processes within a Monitor in Process synchronization MCQs

Q1. What is the simplest approach for determining which suspended process to resume when x.signal() is executed in a monitor?

A.Priority-based scheduling
B.Round-robin scheduling
C.First-come, first-served (FCFS) ordering ✅
D.Shortest job first scheduling
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: FCFS ordering is the simplest solution where the process that has been waiting the longest is resumed first. This approach requires minimal overhead but may not be adequate for all scheduling requirements in monitor implementations.

Q2. What is the primary limitation of using FCFS ordering for process resumption in monitors?

A.It requires too much memory
B.It is not adequate in many circumstances ✅
C.It causes deadlock
D.It violates mutual exclusion
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: FCFS ordering, while simple, is not adequate in many circumstances where more sophisticated scheduling is needed. Priority-based scheduling using conditional-wait constructs provides better control over which process resumes based on specific criteria like resource usage time.

Q3. What is the form of the conditional-wait construct used in monitor implementations?

A.x.wait(c) where c is a priority number ✅
B.x.wait(c) where c is a boolean value
C.x.wait(c) where c is a process ID
D.x.wait(c) where c is the number of processes
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The conditional-wait construct has the form x.wait(c), where c is an integer expression evaluated when wait() is executed. This value, called a priority number, is stored with the suspended process and used to determine resumption order.

Q4. What does the priority number c represent in the conditional-wait construct x.wait(c)?

A.The number of processes waiting
B.The process execution time
C.A scheduling priority value ✅
D.The resource allocation time
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The priority number c is an integer expression evaluated during wait() execution. Its value is stored with the suspended process. When x.signal() executes, the process with the smallest priority number is resumed next, implementing priority-based scheduling.

Q5. When x.signal() is executed with conditional-wait semantics, which suspended process is resumed?

A.The process that has been waiting the longest
B.The process with the smallest priority number ✅
C.The process with the largest priority number
D.A randomly selected process
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When x.signal() is executed with the conditional-wait construct, the process with the smallest priority number (c value) is resumed next. This allows external criteria, such as resource usage time, to determine resumption order rather than simple FCFS.

Q6. What does the ResourceAllocator monitor control?

A.Memory allocation
B.CPU scheduling
C.Single resource allocation ✅
D.I/O device access
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The ResourceAllocator monitor controls the allocation of a single resource among competing processes. It implements scheduling where each process specifies the maximum time it plans to use the resource, and the monitor allocates the resource to the process with the shortest time-allocation request.

Q7. In the ResourceAllocator monitor, what does the acquire(int time) method do?

A.It releases the resource
B.It requests resource allocation with a time limit ✅
C.It checks resource availability
D.It terminates the process
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The acquire(time) method in ResourceAllocator requests resource allocation with a specified maximum usage time. If the resource is busy, the process waits on condition x using wait(time). When the resource becomes available, the process with the shortest requested time is granted access.

Q8. What scheduling algorithm does the ResourceAllocator monitor use?

A.FCFS scheduling
B.Priority-based scheduling
C.Shortest time-allocation request scheduling ✅
D.Round-robin scheduling
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The ResourceAllocator monitor allocates the resource to the process that has the shortest time-allocation request. This uses the conditional-wait construct where the requested time serves as the priority number, and the process with the smallest value is selected for resumption.

Q9. What is the correct sequence for accessing a resource using the ResourceAllocator monitor?

A.acquire(time), access resource, release() ✅
B.release(), access resource, acquire(time)
C.access resource, acquire(time), release()
D.acquire(time), release(), access resource
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The correct sequence for accessing a resource through ResourceAllocator is R.acquire(t) to request access, then access the resource, and finally R.release() to release it. This ensures proper resource management and adherence to the monitor's scheduling algorithm.

Q10. What problem occurs when a process accesses a resource without first gaining access permission from the monitor?

A.Resource deadlock
B.Mutual exclusion violation ✅
C.Priority inversion
D.Resource starvation
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Accessing a resource without gaining permission violates mutual exclusion, as the process bypasses the monitor's gateway. This can lead to race conditions and data corruption. The monitor cannot enforce proper sequencing unless all processes comply with the access protocol.

Q11. Which of the following is NOT a problem that can occur with monitor usage?

A.Process accesses resource without permission
B.Process never releases a resource
C.Process releases a resource it never requested
D.Process completes before resource is released ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: While three problems are identified (accessing without permission, never releasing, and releasing unrequested), completing before resource release is not listed as a problem. The monitor's acquire/release pattern properly handles process completion as long as release() is called.

Q12. What happens if a process requests the same resource twice without first releasing it?

A.The process is granted access immediately
B.The process blocks indefinitely
C.The process may deadlock ✅
D.The monitor ignores the request
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Requesting the same resource twice without releasing it can cause deadlock, as the process may already hold the resource and block waiting for its own release. This violates proper monitor usage and can lead to system deadlock if not prevented.

Q13. Why can't the compiler assist with the correct usage of programmer-defined monitor operations?

A.Monitors are not supported by compilers
B.Compiler cannot enforce application-specific sequences ✅
C.Compiler only checks syntax
D.Compiler lacks mutual exclusion support
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The compiler can enforce syntax but cannot enforce that user processes follow the correct sequence of programmer-defined operations. This limitation means programmers must manually ensure proper sequencing, similar to the concerns that motivated monitor development for semaphores.

Q14. What is one possible solution to ensure proper resource access sequences in the ResourceAllocator monitor?

A.Include resource access operations within the monitor ✅
B.Remove the scheduling algorithm
C.Use semaphores instead
D.Disable mutual exclusion
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: One solution is to include resource access operations within the ResourceAllocator monitor. However, this means scheduling follows the built-in monitor-scheduling algorithm rather than the custom coded scheduling, potentially defeating the purpose of the custom priority-based approach.

Q15. What is the conflict when resource access operations are placed within the monitor?

A.Increased memory usage
B.Built-in scheduler overrides custom scheduling ✅
C.Compiler errors occur
D.Mutual exclusion is lost
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When resource access operations are included within the monitor, scheduling follows the built-in monitor-scheduling algorithm rather than the coded custom algorithm. This conflicts with the need for custom scheduling based on priority numbers and short time allocations.

Q16. What two conditions must be checked to establish correctness of the ResourceAllocator system?

A.Syntax and semantics
B.User process call sequence and mutual-exclusion gateway compliance ✅
C.Priority values and time limits
D.Resource availability and process count
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Two conditions must be checked: First, user processes must always make their calls in a correct sequence. Second, uncooperative processes must not ignore the mutual-exclusion gateway and directly access shared resources. Both conditions are essential for preventing time-dependent errors.

Q17. What happens if user processes do not follow the correct monitor call sequence?

A.The monitor automatically corrects the sequence
B.Time-dependent errors may occur ✅
C.The compiler catches the error
D.The process is terminated
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: If user processes do not follow the correct sequence, time-dependent errors can occur. The monitor cannot enforce sequence correctness; programmers must ensure proper usage. This is similar to semaphore usage concerns that motivated monitor development in the first place.

Q18. What does the mutual-exclusion gateway in a monitor prevent?

A.Processes from entering the monitor
B.Direct access to shared resources without protocols ✅
C.Priority scheduling execution
D.Multiple condition variables
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The mutual-exclusion gateway prevents uncooperative processes from accessing shared resources directly without using the access protocols. This ensures that all resource access goes through the monitor's controlled interface, maintaining data consistency.

Q19. When can we guarantee that no time-dependent errors will occur in the ResourceAllocator system?

A.When priority numbers are properly set
B.When both correctness conditions are ensured ✅
C.When FCFS scheduling is used
D.When the compiler checks all operations
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Time-dependent errors can be guaranteed to be prevented only when both correctness conditions are ensured: correct call sequences and proper mutual-exclusion gateway enforcement. This requires inspecting all programs that use the monitor and its managed resource.

Q20. In Java, what is required to call a synchronized method on an object?

A.Owning the lock for that object ✅
B.Having the highest thread priority
C.Being the first thread created
D.Having the largest thread ID
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: To call a synchronized method in Java, the calling thread must own the lock for the object instance. If the lock is owned by another thread, the calling thread blocks and is placed in the entry set for the object's lock until it becomes available.

Q21. How is a synchronized method declared in Java?

A.public void safeMethod() synchronized
B.public synchronized void safeMethod() ✅
C.synchronized public void safeMethod()
D.public void synchronized safeMethod()
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A synchronized method in Java is declared by placing the synchronized keyword before the return type in the method definition. For example: public synchronized void safeMethod(). This indicates that the method requires owning the object's lock for execution.

Q22. What is the entry set in Java's monitor implementation?

A.The set of threads that have completed execution
B.The set of threads waiting for the object's lock to become available ✅
C.The set of threads currently executing in the monitor
D.The set of threads that own the object's lock
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The entry set represents the set of threads waiting for the object's lock to become available. When a thread calls a synchronized method and the lock is unavailable, the thread blocks and is placed in this entry set until the lock is released by the current owner.

Q23. What happens when a Java thread completes execution of a synchronized method?

A.It enters the entry set
B.It releases the object's lock ✅
C.It signals all waiting threads
D.It increments the priority counter
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a Java thread exits a synchronized method, the lock is released. A thread from the entry set is then selected as the new owner of the lock, allowing it to enter the synchronized method. This ensures mutual exclusion for synchronized methods.

Q24. How are Java's wait() and notify() methods similar to monitor operations?

A.They provide mutual exclusion
B.They are similar to wait() and signal() in monitors ✅
C.They implement semaphore operations
D.They control thread priorities
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Java's wait() and notify() methods are similar in function to the wait() and signal() statements for a monitor. The wait() method causes the current thread to wait until notified, while notify() wakes a waiting thread, analogous to monitor condition variable operations.

Q25. What Java package provides support for semaphores, condition variables, and mutex locks?

A.java.lang
B.java.util
C.java.util.concurrent ✅
D.java.io
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The java.util.concurrent package provides support for semaphores, condition variables, and mutex locks among other concurrency mechanisms. This package offers robust concurrency utilities that implement various synchronization patterns beyond the basic monitor-like functionality.

Q26. What is the key difference between FCFS and priority-based scheduling in monitor process resumption?

A.FCFS uses time, priority uses process ID
B.FCFS resumes longest-waiting; priority resumes based on stored priority numbers ✅
C.FCFS is more efficient; priority is slower
D.FCFS cannot be implemented with semaphores
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: FCFS resumes the process that has been waiting the longest, while priority-based scheduling resumes the process with the smallest priority number (c value). Priority scheduling allows external criteria to influence resumption order, making it more flexible for complex scheduling requirements.

Q27. What is the role of the condition variable x in the ResourceAllocator monitor?

A.To store resource data
B.To suspend processes waiting for the resource ✅
C.To count process requests
D.To track resource usage time
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Condition variable x in ResourceAllocator is used to suspend processes that request the resource when it is busy. The acquire() method calls x.wait(time) to suspend the process, and release() calls x.signal() to resume a waiting process based on its priority number.

Q28. In the ResourceAllocator monitor, what does the busy boolean variable indicate?

A.Whether the monitor is active
B.Whether the resource is currently allocated ✅
C.Whether processes are waiting
D.Whether scheduling is complete
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The busy boolean variable in ResourceAllocator indicates whether the resource is currently allocated to a process. If busy is true, the acquire() method causes the requesting process to wait on condition x. When release() is called, busy is set to false and x.signal() is executed.

Q29. What happens if a process attempts to release a resource that it never requested?

A.The release is ignored
B.The system crashes
C.A process might release an unrequested resource ✅
D.The process is blocked
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: A process might attempt to release a resource that it never requested, which is one of the monitor usage violations. This could corrupt the monitor's state, leading to incorrect resource allocation and potentially allowing multiple processes to believe they own the resource simultaneously.

Q30. Why is inspecting all programs that use the ResourceAllocator monitor necessary?

A.To check for syntax errors
B.To ensure proper sequence and gateway compliance ✅
C.To verify priority numbers
D.To count resource requests
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Inspection is necessary to check two conditions: that user processes make monitor calls in the correct sequence, and that they do not bypass the mutual-exclusion gateway. This ensures correctness and prevents time-dependent errors, but this approach is impractical for large or dynamic systems.

Q31. What is the fundamental limitation of the inspection approach for ensuring monitor correctness?

A.It requires too much memory
B.It is not reasonable for large or dynamic systems ✅
C.It cannot detect priority inversion
D.It conflicts with compiler optimization
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: While inspection may be possible for small, static systems, it is not reasonable for large or dynamic systems. Manual verification of all programs using a monitor becomes impractical as system scale grows, requiring more automated verification techniques or design patterns that enforce correct usage.

Q32. Which of the following correctly describes the Java object lock mechanism?

A.Every class has a single static lock
B.Every object has an associated lock ✅
C.Only synchronized objects have locks
D.Locks are per-thread, not per-object
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In Java, every object has an associated single lock. When a synchronized method is called, the calling thread must own this lock. This per-object lock mechanism provides fine-grained synchronization at the object level, allowing different objects to be synchronized independently.

Q33. What determines which thread is selected as the new owner of a Java object's lock when it is released?

A.Thread priority
B.The scheduling policy ✅
C.Number of synchronized methods called
D.Thread creation order
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a Java object's lock is released, a thread from the entry set is selected as the new owner. While the exact selection mechanism is platform-dependent, the Java scheduling policy determines which thread is chosen, not a predetermined rule like FIFO or priority-based selection.

Q34. In Java's monitor implementation, what causes a thread calling a synchronized method to block?

A.Lack of memory resources
B.The lock being already owned by another thread ✅
C.The method being static
D.The thread having low priority
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A thread calling a synchronized method blocks if the object's lock is already owned by another thread. The blocking thread is placed in the entry set for the object's lock and waits until the lock becomes available and the scheduler selects it as the new owner.

Q35. How does Java's notify() method relate to the monitor signal operation?

A.It wakes all waiting threads
B.It is similar to signal() for waking one waiting thread ✅
C.It releases the object lock
D.It increases the priority of waiting threads
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Java's notify() method is similar to the monitor signal() operation in that it wakes one thread that is waiting on the object's lock. While monitor implementations may vary, both operations serve to resume a waiting thread, allowing it to re-enter the synchronized region.

Q36. What is the significance of the priority number being stored with the process name in conditional-wait?

A.It tracks process execution time
B.It determines resumption order ✅
C.It identifies process owner
D.It validates resource access
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The priority number is stored with the process name, allowing the monitor to make scheduling decisions based on these stored values. When x.signal() is called, the monitor selects the process with the smallest stored priority number for resumption, enabling custom scheduling policies.

Q37. What difficulty arises when resource access operations are placed within the ResourceAllocator monitor?

A.The monitor becomes too complex
B.Built-in scheduling overrides custom scheduling ✅
C.Mutual exclusion is compromised
D.Priority inversion occurs
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Placing resource access operations within the monitor results in scheduling following the built-in monitor-scheduling algorithm rather than the custom priority-based algorithm. This defeats the purpose of the conditional-wait construct and the shortest time-allocation scheduling that was originally intended.

Q38. What is the role of the acquire() method's time parameter in the ResourceAllocator monitor?

A.It specifies the maximum time the process plans to use the resource ✅
B.It sets the process execution priority
C.It determines the process ID
D.It initializes the condition variable
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The time parameter in acquire(int time) specifies the maximum time the process plans to use the resource. This value serves as the priority number in the conditional-wait construct, allowing the monitor to allocate the resource to the process with the shortest requested usage time.

🔗 Related Topics (MCQs)