Reputation: 987
Scheduler is a program , that schedules different processes in the OS. The question that came in mind is:
Since scheduler is also a process , and it is scheduling other processes by context switching. So , there will be a time when , scheduler will it self get switched with any other process. If this happens then how the scheduling happens after that.
Or , If it is not like that, then hw does it work, as in a multitasking system, In order to run different processes together , the processes has to be context switched, and if scheduler is running all the time then, how will it give space for other processes to run together.
Upvotes: 1
Views: 190
Reputation: 6575
The scheduler is a program, yes, but very rarely is it a process. Rather the schedule is part of the Kernel, or the program that abstracts processes from the hardware (including the processor usage).
In a preemptive scheduler, Since the scheduler is part of the kernel, it actually exists in the address space of every single process. When a process's alloted time is up, the scheduler takes control of program execution and then does the necessary work to move to the next process. When the schedule does this, however, it does not remove itself from the new process's address space so that when the new process's time is up, it can saftely perform the work needed to move on.
While there have been kernels whose functions were often offloaded into other processes (CMU Mach), there will always be a part of the kernel that retains functionality for changing processes, and this will never be exclusively in its own process.
For more information on how scheduling works, I find the following articles helpful:
http://wiki.osdev.org/Context_Switching
http://wiki.osdev.org/Scheduling_Algorithms
http://wiki.osdev.org/Processes_and_Threads
Upvotes: 2