OS Scheduling
OS Scheduling
139 139
Monday, February 24, 2025 Biju K Raveendran @ BITS Pilani Goa 10
• schedule()
– Selects a process from the runqueue list and
assign CPU to it.
– Invoked directly or lazy (deferred) way
• Direct
– The current process is blocked right away because the
resource it needs is not available.
• Lazy invocation
– By setting the TIF_NEED_RESCHED flag of current
process to 1
– Check on the value of this flag is made before resuming
the execution of a User Mode Process
Monday, February 24, 2025 Biju K Raveendran @ BITS Pilani Goa 11
• Examples of lazy invocation
– When current process has used up its quantum time
(done by scheduler_tick() function)
– When a process is woken up and its priority is higher
than that of the current process (done by
try_to_wake_up() function)
– When a sched_setscheduler() system call is issued
• load_balance()
– Keeps the runqueues of a multiprocessor system
balanced