📝 Scheduler activations in operating system (33 MCQs)
Coordination Between User-Level and Kernel-Level Threads
Scheduler activations are a historical mechanism for coordinating user-level thread libraries with kernel scheduling in a many-to-many threading environment. The kernel provides virtual processors, commonly described as lightweight processes, through which user threads can execute. It also sends upcalls to notify the user-level scheduler about events such as blocking and processor allocation changes, allowing the runtime to adjust thread scheduling.
Why User and Kernel Schedulers Need Coordination
User-level thread libraries can manage application threads efficiently, but the kernel may block or preempt their underlying execution entities without directly understanding the library's thread states. This can leave the runtime unaware that execution capacity has changed. Scheduler activations address the coordination gap by informing the user scheduler about relevant kernel events and resource availability.
Virtual Processors, Upcalls, and Thread-State Recovery
The kernel allocates virtual processors for user-level thread execution and notifies the user scheduler through upcalls when scheduling events occur. If a running thread blocks in the kernel, the runtime can schedule another eligible user thread on an available execution entity. When the blocked operation completes, the kernel communicates the event so the runtime can restore scheduling capacity.
Handling a Blocking System Call in a User Thread
Suppose three user threads share two virtual processors. One thread performs a blocking disk operation. The kernel notifies the user-level scheduler that one execution entity is blocked, allowing the runtime to schedule another ready thread on available capacity. When the disk operation completes, an upcall informs the runtime that the blocked thread can become eligible again.
Flexible Thread Scheduling and Coordination Complexity
Scheduler activations were designed to combine efficient user-level thread management with kernel awareness of blocking and processor allocation. They offered a model for scalable many-to-many threading. However, implementation complexity, coordination overhead, and the need for close runtime-kernel cooperation limited widespread adoption. Modern threading systems commonly use different kernel-thread arrangements rather than this historical mechanism.
Misconceptions About Scheduler Activation Events
'An upcall is an ordinary application system call' is incorrect because it is a kernel-originated notification to the user-level scheduler. 'A virtual processor is always a physical CPU core' is incorrect because it is an execution abstraction. 'Scheduler activations eliminate kernel scheduling' is incorrect because the kernel still manages underlying execution resources.
Exam Focus: Upcalls and User-Kernel Scheduler Interaction
Explain the roles of virtual processors, lightweight processes, user-level schedulers, and kernel upcalls. Trace what happens when a user thread blocks and later becomes runnable. Questions may compare scheduler activations with many-to-many mapping and identify how kernel notifications help maintain usable execution capacity.
Key Terms of Scheduler Activations
- Scheduler activation - User-kernel scheduling coordination mechanism.
- Upcall - Kernel notification to user-level code.
- Virtual processor - Execution resource supplied to a runtime.
- Lightweight process - Kernel-supported execution entity.
- User scheduler - Runtime managing user threads.
- Blocking event - Event suspending an execution entity.
📝 All Scheduler activations in operating system MCQs
Q1. A language runtime manages many user-level threads over a few kernel-supported execution entities. The kernel can block or preempt an entity without knowing which application thread it was running. What coordination problem does this create?
📖 Explanation: The kernel can change execution state without exposing the affected user-level thread to the runtime. Scheduler activations address this information gap by delivering kernel events so the user scheduler can update its state and decisions.
Q2. In a scheduler-activation design, which allocation of responsibilities is correct?
📖 Explanation: The kernel controls how many processors an address space receives, while its user-level scheduler selects application threads for those processors. This division preserves kernel control over machine resources and runtime control over application-level scheduling policy.
Q3. A runtime is told that its process currently has three processors and later receives notice that one has been reassigned elsewhere. Which interpretation of its virtual multiprocessor is correct?
📖 Explanation: A virtual multiprocessor presents the processors currently allocated to an address space as its execution resource. The kernel may increase or decrease that allocation, so the runtime must track changes rather than assume permanence.
Q4. Which description captures the three principal functions of a scheduler activation?
📖 Explanation: A scheduler activation is an execution context for user-level work, a vehicle for notifying the runtime about a kernel event, and a place in which the stopped thread's processor state can be saved for later recovery.
Q5. A kernel detects that an execution event requires attention from a process's user-level thread manager. What does an upcall do in this design?
📖 Explanation: An upcall is initiated by the kernel and enters the address space's thread-management code. It reports a kernel event in a scheduler-activation context, allowing the runtime to update thread state and choose subsequent work.
Q6. A process has three runnable user threads and two allocated execution contexts. One running thread blocks in a disk read. What is the intended immediate response?
📖 Explanation: The blocking event must be reported so the runtime can stop treating the affected execution context as occupied by that thread. It can then dispatch another ready user thread on available processor capacity.
Q7. A student says that when a user-level thread blocked in the kernel becomes unblocked, the kernel simply resumes that same thread in its old scheduler activation. Which correction is most accurate?
📖 Explanation: The flawed step is assuming direct resumption in the old activation. The kernel reports the unblocking event through an activation, and the runtime returns the affected user thread to its scheduling structures before selecting work.
Q8. After an I/O completion notification, a previously blocked user-level thread is eligible to run again. What should the runtime normally do with that thread first?
📖 Explanation: I/O completion changes the thread from blocked to eligible, not automatically to executing. The runtime records it as ready and chooses which eligible thread should use an available scheduler activation under its own policy.
Q9. In the described implementation, a scheduler activation has separate kernel and application-address-space stacks. When a user-level thread traps into the kernel, which stack is used for the kernel-side execution?
📖 Explanation: Each activation has a kernel-mapped stack and an application-mapped stack. A user-level thread uses the activation's kernel stack when it enters the kernel, while the runtime scheduler executes on the application-side stack.
Q10. An application has five runnable user-level threads throughout an interval. Its allocated execution contexts are shown as (time, contexts): (0,3); (1,2); (2,2); (3,4); (4,3); (5,1). At time 3, what is the maximum number of these threads that can execute simultaneously?
📖 Explanation: At time 3 the plot gives four allocated execution contexts. Even though five threads are runnable, simultaneous execution is bounded by available contexts, so the maximum is threads at that observation.
Q11. An engineer manages 120 user-level threads on four kernel-supported lightweight processes (LWPs). Which interpretation of this arrangement is correct?
📖 Explanation: The kernel supplies a limited number of execution contexts to the address space, while the user-level scheduler multiplexes many application threads over them. The mapping is not necessarily one kernel entity per user-level thread.
Q12. A developer claims that an I/O completion makes the kernel directly resume the blocked user-level thread without notifying the runtime. What is the specific flaw in this reasoning?
📖 Explanation: The flawed step is bypassing the user scheduler. An unblocking event is delivered to the runtime, which updates the ready list and chooses a thread; the kernel does not independently select that user-level thread.
Q13. A program begins with one allocated processor and then the kernel grants it a second. How is the new capacity normally exposed to the user-level thread system?
📖 Explanation: When another processor is assigned, the kernel creates an activation for that execution resource and enters the user-level scheduler through an upcall. The runtime can then choose a ready thread to run there.
Q14. A multiprogrammed system reclaims one processor from an address space that was running a user-level thread on it. What information must the affected runtime receive?
📖 Explanation: The runtime must learn that its processor allocation has decreased and identify the user thread stopped on the reclaimed activation. It can then update the ready list and schedule remaining work on processors still assigned.
Q15. A blocking event and a processor reallocation event occur close together and both require runtime attention. Which notification behavior is supported by this design?
📖 Explanation: When kernel events occur in combination, one upcall can communicate all events that need handling. The user-level scheduler processes the combined state changes rather than assuming that every event requires a separate entry.
Q16. A runtime receives notice that one user-level thread blocked, but its event handler marks every thread in the process as blocked. What is the main error?
📖 Explanation: The flawed update spreads one thread's blocking condition to unrelated threads. Only the affected thread should become blocked; other ready threads must remain eligible so the runtime can use available execution capacity.
Q17. A runtime's ready queue grows beyond the number of processors currently allocated to its address space. Which user-to-kernel communication is appropriate?
📖 Explanation: When runnable parallelism exceeds allocated processor capacity, the address space can tell the kernel that it needs more processors. This information informs allocation policy, but it does not guarantee an immediate grant.
Q18. A runtime has four allocated processors but only two runnable user threads. What should it communicate when an execution context is genuinely idle and available for reassignment?
📖 Explanation: The runtime can report an idle processor so the kernel may reassign it to another address space. This avoids retaining execution capacity that the application currently cannot use for runnable work.
Q19. An application has three allocated processors throughout the interval. The graph gives (time, runnable user threads): (0,2); (1,3); (2,4); (3,5); (4,2); (5,1). At what earliest time does runnable work exceed allocated processor capacity?
📖 Explanation: With three processors, the queue first exceeds capacity when its runnable count becomes four. The sequence is two, three, then four, so the first excess occurs at time 2, not when the counts are equal.
Q20. Why does the user-level thread system notify the kernel about only a subset of its thread operations rather than every creation, dispatch, or context switch?
📖 Explanation: Most user-level scheduling operations do not change how many processors the address space needs. Reporting only allocation-relevant transitions preserves the low cost of common runtime operations while still informing the kernel when resource demand changes.
Q21. A student argues that every user-level thread creation and every user-level context switch must trap into the kernel, because the kernel alone decides which application thread runs next. Which correction fixes the reasoning?
📖 Explanation: The mistaken assumption gives the kernel responsibility for every application-thread choice. The runtime handles ordinary user-level scheduling locally and communicates only the subset of state changes relevant to the kernel's processor-allocation decisions.
Q22. A server has 120 runnable user-level threads but receives four execution contexts from the kernel. Which statement correctly distinguishes concurrency from simultaneous parallel execution?
📖 Explanation: Concurrency allows many threads to make progress through scheduling over time, whereas simultaneous execution requires a processor context. With four allocated contexts, at most four of the 120 runnable threads execute at once.
Q23. A language runtime uses scheduler activations so that ordinary user-thread operations remain local, while kernel events are reported when necessary. Which performance benefit is the design intended to preserve?
📖 Explanation: The design keeps frequent thread operations in the user-level runtime, avoiding unnecessary protection-boundary crossings. Kernel notifications still provide system integration for blocking and processor changes, balancing efficiency with correct scheduling information.
Q24. A media server spends much of its time waiting for disk and network operations, while several other user-level threads remain ready. Why is coordinated scheduling especially useful for this workload?
📖 Explanation: Blocking-heavy workloads frequently change which execution contexts can run useful work. Notifications let the runtime react to those changes and dispatch ready threads, reducing avoidable idle intervals while I/O remains pending.
Q25. A graph lists (allocated processors, runnable user threads) at six observations: (1,3); (2,5); (3,4); (4,2); (5,1); (6,5). At which observation is surplus allocated capacity over runnable work greatest?
📖 Explanation: Surplus capacity is allocated processors minus runnable threads. The values are negative, negative, negative, two, four, and one; therefore the greatest surplus is at (5,1), with idle contexts, exceeding every other plotted surplus.
Q26. During a preemption, a user-level thread is interrupted while holding the runtime's ready-list lock. The new upcall also needs that lock to place the interrupted thread back on the ready list. What recovery approach prevents deadlock?
📖 Explanation: If the interrupted thread holds the ready-list lock, the upcall cannot safely acquire it while that thread remains stopped. Continuing the lock holder until it exits the critical section lets event handling proceed safely.
Q27. A user-level thread holds a spin-lock when its underlying execution is preempted. Other user threads continue spinning on that lock. Which consequence explains why kernel preemption must be communicated to the runtime?
📖 Explanation: Preempting a lock holder can leave other threads spinning without progress because the owner is not executing to release the lock. Event notification lets the runtime recognize and handle this unsafe preemption situation.
Q28. A student claims that the kernel understands every user-level mutex and automatically releases any lock held by a thread before sending a preemption upcall. What is wrong with this explanation?
📖 Explanation: The flawed step assumes kernel knowledge of application-level synchronization structures. The kernel reports the preemption and saved state, while the runtime must detect critical-section conditions and use its own recovery protocol.
Q29. A user thread faults while running on an activation. The runtime already maintains the thread's stack and control block. Which state is particularly important for the kernel to save and provide with the notification?
📖 Explanation: The runtime retains the thread's stack and control block, but the interrupted register state must be preserved by low-level kernel handling. That machine state is supplied with the notification so the runtime can resume correctly.
Q30. A user thread is blocked on I/O. When the I/O completes, the kernel must also preempt one processor currently assigned to the same address space to perform the notification. What should the combined upcall enable the runtime to do?
📖 Explanation: The upcall can report both I/O completion and processor preemption together. The runtime makes the unblocked and preempted user threads ready, then selects work according to its policy and the remaining allocation.
Q31. A process has two allocated processors running user threads U1 and U2, while U3 and U4 are ready. U1 blocks, and the runtime schedules U3 on the freed execution capacity. Later, the kernel reclaims one processor for another address space. What must happen to the user thread stopped on that reclaimed processor?
📖 Explanation: Reclaiming a processor stops the activation and its current user thread, but does not imply that the user thread has terminated. The upcall gives the runtime its state so it can reschedule that thread later.
Q32. A runtime requests two additional processors because it has more runnable threads than allocated contexts. Before the kernel grants them, several threads block, leaving no extra runnable work. If a requested processor is nevertheless assigned, what should the runtime do?
📖 Explanation: Processor-demand notifications are hints because workload parallelism can change before allocation occurs. If a granted processor is no longer useful, the runtime should report it idle so the kernel can reassign it.
Q33. A runtime uses scheduler activations and receives every relevant kernel notification, but its own policy continually favors one high-priority user thread while lower-priority runnable threads wait. Which conclusion is justified?
📖 Explanation: Scheduler activations coordinate kernel events and processor resources; they do not prescribe a fair user-level scheduling policy. A runtime that persistently favors one thread can still starve others unless its own policy prevents it.