What is Scheduler in Operating System ?
If we consider batch systems, there will often be more processes submitted than the number of processes that can be executed immediately. So incoming processes are spooled (to a disk).
The long-term scheduler selects processes from this process pool and loads selected processes into memory for execution.
The short-term scheduler selects the process to get the processor from among the processes which are already in memory.
The short-time scheduler will be executing frequently (mostly at least once every 10 milliseconds). So it has to be very fast in order to achieve a better processor utilization. The short-time scheduler, like all other OS programs, has to execute on the processor. If it takes 1 millisecond to choose a process that means ( 1 / ( 10 + 1 )) = 9% of the processor time is being used for short time scheduling and only 91% may be used by processes for execution.
The long-term scheduler on the other hand executes much less frequently. It controls the degree of multi-programming (no. of processes in memory at a time). If the degree of multi-programming is to be kept stable (say 10 processes at a time), then the long-term scheduler may only need to be invoked when a process finishes execution.
The long-term scheduler must select a good process mix of I/O-bound and processor bound processes. If most of the processes selected are I/O-bound, then the ready queue will almost be empty while the device queue(s) will be very crowded. If most of the processes are processor-bound, then the device queue(s) will almost be empty while the ready queue is very crowded and that will cause the short-term scheduler to be invoked very frequently. Time-sharing systems (mostly) have no long-term scheduler.
The stability of these systems either depends upon a physical limitation (no. of available terminals) or the self-adjusting nature of users (if you can’t get response, you quit).
It can sometimes be good to reduce the degree of multi-programming by removing processes from memory and storing them on disk. These processes can then be reintroduced into memory by the medium-term scheduler. This operation is also known as swapping. Swapping may be necessary to improve the process mix or to free memory.