Difference between Short-Term, Medium Term, and Long-Term Scheduler
Process scheduling is an important activity done by the process manager to remove the process from the CPU and schedule the next process, the process removal and dispatch are based on multiple factors like process completion, priority, I/O requirement, etc. Process scheduling plays important role in Multiprogramming operating systems. There are mainly three types of schedulers in operating systems, which are: Short-term schedulers, medium-term schedulers, and long-term schedulers.
The short-term scheduler selects processes from the ready queue that are residing in the main memory and allocates CPU to one of them. Thus, it plans the scheduling of the processes that are in a ready state. It is also known as a CPU scheduler. As compared to long-term schedulers, a short-term scheduler has to be used very often i. e. the frequency of execution of short-term schedulers is high. The short-term scheduler is invoked whenever an event occurs. Such an event may lead to the interruption of the current process or it may provide an opportunity to preempt the currently running process in favor of another. The example of such events are:
- Clock ticks (time-based interrupts)
- I/O interrupts and 1/0 completions.
- Operating system calls
- Sending and receiving of signals.
- Activation of the interactive program.
The medium-term scheduler is required at the times when a suspended or swapped-out process is to be brought into a pool of ready processes. A running process may be suspended because of an I/O request or by a system call. Such a suspended process is then removed from the main memory and is stored in a swapped queue in the secondary memory in order to create a space for some other process in the main memory. This is done because there is a limit on the number of active processes that can reside in the main memory. The medium-term scheduler is in charge of handling the swapped-out process. It has nothing to do with when a process remains suspended. However, once the suspending condition is removed, the medium terms scheduler attempts to allocate the required amount of main memory and swap the process in & make it ready. Thus, the medium-term scheduler plans the CPU scheduling for processes that have been waiting for the completion of another process or an I/O task.
The long-term scheduler works with the batch queue and selects the next batch job to be executed. Thus it plans the CPU scheduling for batch jobs. Processes, which are resource intensive and have a low priority are called batch jobs. These jobs are executed in a group or bunch. For example, a user requests for printing a bunch of files. We can also say that a long-term scheduler selects the processes or jobs from secondary storage device eg, a disk and loads them into the memory for execution. It is also known as a job scheduler. The long-term scheduler is called “long-term” because the time for which the scheduling is valid is long. This scheduler shows the best performance by selecting a good process mix of I/O-bound and CPU-bound processes. I/O bound processes are those that spend most of their time in I/O than computing. A CPU-bound process is one that spends most of its time in computations rather than generating I/O requests.
Difference between Short-Term, Medium term, and Long-Term Schedulers:
|Basis||Short-Term Scheduler||Medium-term Scheduler||Long-Term Scheduler|
|1. Alternate Name||It is also called a CPU scheduler.||It is also called a process swapping scheduler.||It is also called a job scheduler.|
|2. Degree in programming||It provides lesser control over the degree of multiprogramming.||It reduces the control over the degree of multiprogramming.||It controls the degree of multiprogramming.|
|3. Speed||The speed of the short-term scheduler is very fast.||Speed of medium scheduler between the short-term and long-term scheduler||The speed of a long-term term scheduler is more than medium-term scheduler.|
|4. Usage in time- sharing system sharing system||It is minimal in the time-sharing system.||It is a part of the time-sharing system.||It is almost absent or minimal in a sharing system.|
|5. Purpose||It selects the processes from among the process that is ready to execute.||It can reintroduce the from among the process into memory that executes and its execution can be continued.||It selects processes from the pool and loads them into memory for execution.|