- A scheduler is an operating system module that selects the next job or process to be admitted into the system.
- Thus, a scheduler selects one of the processes from among the processes in the memory that are ready to execute and allocates CPU to it.
- In a complex operating system three different types of schedulers may exist.
- Long-term scheduler
- Medium term scheduler
- Short term scheduler
- Submitted job joins the batch queue while waiting to be processed by the long-term scheduler.
- Once a process is scheduled for execution, the process spawned by the batch job enter the ready queue where it waits for the allocation of processor. The processes in read queue are selected for the execution by the short term scheduler.
- After becoming suspended, the running process may be removed from memory an swapped out to secondary storage. Such processes are subsequently admitted to ma memory by the medium-term scheduler in order to be considered for execution by ti short term scheduler.
1. Long-term scheduler
- The long term scheduler works with batch queue and selects the next batch job executed. Thus it plans the CPU scheduling for batch jobs. Processes, which are resource intensive and have a low priority are called batch These jobs are executed in a group or bunch. For example, a user request for prate bunch of files.
- We can also say that a long term scheduler selects the processes or job from secondary storage device e.g. a disk and loads them into the memory for execution. t is also know as job scheduler.
- The frequency of execution of a long-term scheduler is usually low, as there may be minutes between the creation of new processes in the system.
- The long term scheduler is called “long-term” because the time for which the scheduling is valid is long.
- The primary objective of long term scheduler is to control the degree of multiprogramming. The degree of multiprogramming refers to the total number of processes present in the memory. If the degree of multiprogramming is stable, then the average rate of process creation is equal to the average departure rate. Therefore the long-term scheduler may need to be invoked only when the process leaves the system.
- This scheduler shows the best performance by selecting the good process mix of 1/0 bound and CPU-bound process. I/O bound processes are those that spend most of their time in I/O than computing. CPU bound process are those that spend most of their time in computations rather than generating I/O requests.
- On some systems, the long-term scheduler may be absent or minimal. For example. timesharing systems such as UNIX often have no long term scheduler but simply put every new process in memory for the short term scheduler.
2. Medium term schedulers
- The medium term scheduler is required at the times when a suspended or swapped-out process is to be brought into pool of ready processes
- A running process may be suspended because of I/O request or by a system call. Such a suspended process is then removed from main memory and is stored in swapped out 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 main memory.
- Therefore, a suspended process is swapped-out or rolled out of main memory.
- At some later time, the process can be reintroduced i.e. swapped in the main memory so that it can continue where it left off.
- Thus, swapping is required to control the degree of multiprogramming. All version of windows operating system use swapping.
- The medium-term scheduler is in-charge of handling swapped out process. It has nothing to do, 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, medium term scheduler plans the CPU scheduling for processes that have ben waiting for completion of another process or an I/O task.
- To work properly, the medium term scheduler must be with information about the memory requirements of swapped out process.
3. Short-term scheduler
- The short-term scheduler selects from among the ready processes 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 ready state.
- Short term scheduler is also known as CPU scheduler.
- As compared to long term schedulers, a short term scheduler has to work very often i.e. the frequency of execution of short-term scheduler is high.
- The short term scheduler must select a new process for CPU frequently. A process may execute for only a few milliseconds before waiting for an I/O request. Often, the short- term scheduler executes at least once every 100 milliseconds. Because of the brief time between executions, the short-term scheduler must be fast.
- 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 current running process in favor of another.
The example of such events are:
- Clock-ticks (time based interrupts)
- I/O interrupts and I/O completions.
- Operating system calls.
- Sending and receiving of signals.
- Activation of interactive program.
Hello, this weekend is pleasant for me, because this time i am reading this enormous informative post here at my house.