written 2.7 years ago by |
Solution:
Scheduler:
The operating system must select, for scheduling purposes, processes from these queues in some fashion. The selection process is carried out by the appropriate scheduler.
Often, in a batch system, more processes are submitted than can be executed immediately.
These processes are spooled to a mass-storage device (typically a disk), where they are kept for later execution.
These goals often conflict , thus a scheduler will implement a suitable compromise. Preference is measured by any one of the concerns mentioned above, depending upon the user's needs and objectives.
Their main task is to select the jobs to be submitted into the system and to decide which process to run.
There are three types of scheduler −
1) Long-Term Scheduler.
2) Short-Term Scheduler.
3) Medium-Term Scheduler.
(1) Long- Term scheduler:
The long-term scheduler, or job scheduler, selects processes from this pool and loads them into memory for execution.
It's decides which jobs or processes are to be admitted to the ready queue (in main memory); that is, when an attempt is made to execute a program, its admission to the set of currently executing processes is either authorized or delayed by the long-term scheduler.
It also controls the degree of multiprogramming. If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of processes leaving the system.
If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of processes leaving the system.
Thus, the long-term scheduler may need to be invoked only when a process leaves the system.
Because of the longer interval betweenexecutions, the long-term scheduler can afford to take more time to decide which process should be selected for execution.
(2) Short-Term Scheduler:
The short-term scheduler must select a new process for the CPU frequently.
The short-term scheduler makes scheduling decisions much more frequently than the long-term and mid-term schedulers, a scheduling decision will at a minimum have to be made after every time slice, and these are very short.
The short-term scheduler, or CPU scheduler, selects from among the processes that are ready to execute and allocates the CPU to one of them.
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 short time between executions, the short-term scheduler must be fast.
3) Medium-Term Scheduler:
The medium-term scheduler temporarily removes processes from main memory ,and places them in secondary memory. which is commonly referred to as swapping.
The medium-term scheduler is in-charge of handling the swapped out-processes.
In this condition, to remove the process from memory and make space for other processes, the suspended process is moved to the secondary storage, This process is called swapping processes.