There are two cases where the scheduler code schedule()
is invoked-
When a process voluntarily calls schedule()
Timer interrupt calls schedule()
In case 2, I think schedule()
runs in interrupt context, but what about the first case? Does it run in the context of the process which invoked it?
Also are there any more scenarios which invoke schedule()
?
The kernel's process / thread scheduler runs on the core that needs to figure out what to do next. It's a distributed algorithm with no single decision-making thread. Scheduling doesn't work by figuring out what task should run on which other CPU.
In operating system the scheduler is invoked after the system call api or after a hardware interrupt processing.
The task scheduler, sometimes called process scheduler, is the part of the kernel that decides which task to run next. It is responsible for best using system resources to guarantee that multiple tasks are being executed simultaneously. This makes it a core component of any multitasking operating system.
O(1) Scheduler was introduced in LINUX Kernel 2.6. O(1) scheduler is also called as Big O of 1 scheduler or constant time scheduler. As the name suggests, it can schedule the processes within a constant amount of time, regardless of the number of processes running on the system. O(1) scheduler uses two queues.
schedule()
always runs in process context. In the second case, when it is initiated by a timer interrupt, it is in the return path back from the kernel to the interrupted process where schedule()
is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With