- LPU MCA Semester 1
- CAP366
- Unit 4
CAP366 · Unit 4: CPU scheduling
Scheduling in Windows and Linux
10 practice questions · in the MTE and ETE syllabus
Key points
- Windows: 32 priority levels, preemptive
- Idle thread runs when nothing is ready
- CFS picks the smallest vruntime
- Lower nice value = higher priority
Windows uses a priority-driven, preemptive scheduler with 32 priority levels: variable class 1-15, real-time class 16-31, and priority 0 for the memory-management thread. A higher-priority ready thread preempts a lower-priority running thread at once; the dispatcher runs an idle thread when nothing is ready.
Linux uses the Completely Fair Scheduler (CFS) (the classic textbook version): there is no fixed time slice; each task tracks vruntime and the task with the smallest vruntime runs next, kept in a red-black tree. Nice values run from -20 to +19, and a lower nice value means higher priority and a larger share. Real-time tasks use a separate class.
| Windows | Linux CFS | |
|---|---|---|
| Key idea | Priority, preemptive | Fairness via vruntime |
| Pick next | Highest priority | Smallest vruntime |
Exam pitfall: a task that sleeps a lot has low vruntime, so interactive tasks get picked quickly on waking; do not confuse nice (lower = higher priority) with a priority number.
Try two questions
In Windows, a ready thread of priority 8 has been starved of the CPU for several seconds because higher-priority threads keep the CPU busy. What does the system do?
- The balance-set manager temporarily boosts it to priority 15 so it can run
- It raises the thread permanently into the real-time class
- It terminates the thread because it exceeded its wait limit
- It lowers the thread's priority until the CPU becomes free
Show the answer
A. The balance-set manager boosts threads that are ready but starved to priority 15 for a short time to avoid starvation.
Why not B: The boost is temporary, and starved threads are not moved into the real-time class.
Why not C: Windows does not kill starved threads.
Why not D: Lowering the priority would make starvation worse.
Two CPU-bound tasks share one core under Linux CFS. Task A has nice 0 (weight 1024) and task B has nice 5 (weight 335). About what share of the CPU does A receive?
- 50%
- 60%
- 90%
- 75%
Show the answer
D. CFS gives shares in proportion to weight, so A gets 1024 / (1024 + 335) = about 75 percent.
Why not A: Equal shares would apply only if both had the same weight.
Why not B: This understates the weight ratio of roughly 3 to 1.
Why not C: This overstates the ratio; the weights are not 9 to 1.