When is the scheduler called?


Direct invocation
During System Calls
Mostly indirectly via sleep_on()
e.g. when waiting for a resource


Lazy invocation
After System Calls or interrupts
if need_resched is set
e.g. after sched_set_scheduler()
The timer interupt also sets need_resched, making sure that schedule() is called frequently