- A process transfers between various scheduling queues throughout its lifetime.
- The operating system must select a process from these queues in some order for scheduling purposes.
- The selection process is done by the appropriate scheduler. There are two types of schedulers:
- Long term scheduler (job scheduler )
- Short term scheduler ( CPU scheduler )
Long Term Scheduler
- The long term scheduler selects the processes from the job pool and loads them into memory for execution.
- Long term scheduler is also referred to as Job Scheduler.
- The long term scheduler executes less frequently.
- The long term scheduler control the degree of multi-programming ( the number of processes in the memory ).
Short Term Scheduler
- The short term scheduler selects process from among the processes that are ready to execute and allocates the CPU to one of them.
- It is also referred to as CPU Scheduler.
- Main difference between these two schedulers is the frequency of their execution.
- The short term scheduler must select a new process for the CPU frequently.
- Processes can be described as either input/output bound process that spends more of its time doing input/output then doing its computation.
- A CPU bound process, generates an input/output request infrequently.
- It uses more of its time doing computation than an input/output bound.
- The long term scheduler selects a process mixing of input/output bound and CPU bound processes.
- If all processes are input/output bound, the ready queue will be always empty and so short term scheduler will have little work to do.
- If all processes are CPU bound, the input/output waiting queue will almost always be empty, at that time devices are not used and all processes perform its work with memory.
- When any of these queue is empty, the system will be in unbalanced state.
- The system with good performance will have combination of CPU bound and input/output bound processes.
- Another component involved in CPU scheduling is dispatcher. The dispatcher is the module that gives control to the CPU to the process selected by short term scheduler. The functions performed by dispatcher are as follows:
- Switching context
- Switching to user mode
- Jumping to the proper location in the user program to restart that program.
- The dispatcher should be as fast as possible given that it is involved during every process switch. The time it takes for dispatcher to stop one process and start another running is known as Dispatch Latency.