The goal of a multiprogramming system tries to keep the CPU busy at all times. For a Time-sharing system, the goal is to switch between user processes so that each user can interact with the process. So, to meet these goals a scheduler selects one out of many available processes for execution by the CPU. There are different types of schedulers in operating system – long term scheduler, short term scheduler and medium-term scheduler.
A queuing diagram as shown in the figure below represents the scheduling process. There are Two queues – ready queue and device queue. A new process is first admitted into the ready queue. It waits until it is dispatched (allocated to the CPU for execution).
Once the process starts executing by the CPU, five possibilities arise:
The job queue consists of all process generated in the system. These reside in the secondary storage. Since, the size of secondary storage device is more than the RAM, all the processes in the job queue can not be accomodated in the RAM. Hence, to select a few out of all the processes in the Job queue is the task of the Long Term Scheduler.
All the processes in the RAM reside in the ready queue. Since there is one CPU, so the OS selects only one process from the ready queue to allocate to the CPU. This selection is made by the OS module known as Short Term Scheduler.
A process is of two types –
CPU bound process – if it spends most of its time with CPU) process
I/O bound process – if it spends most of its time with I/O devices).
It is important to have a mix of CPU bound and I/O bound process in the RAM (to use all the resources). Since the system can not determine whether a process is CPU or I/O until it is run atleast once the selection done by long-term scheduler might consist of mostly CPU or mostly I/O processes. Hence, if the mix is not good then the OS swaps some of the processes with those in the job queue. This swapping is the task of the Medium-term scheduler. Finally, the swapping may also be required to lower the degree of multi-programming or to incorporate a higher priority process in the RAM if sufficient space is not there in RAM.
Note: Refer the video lecture for more details on types of Schedulers
Which Process controls the degree of multi-programming?
Whenever the CPU shifts from one process to another it need to save the context of the running process so that it can be loaded again when it gets the CPU next time. Therefore, this context is represented in the PCB of the process. Switching the CPU from one process to another process requires performing a state save of the current process and a state restore of a different process. This task is known as context switch
Note: Clicking on the “next” slide button will not display any animation. Hence, Click within the slide area for animations.
Previous Next Process and Process states Operations on Process