ARTICLE: Operating System – Process Scheduling

WHAT IS PROCESS SCHEDULING?

The activity of the process manager to handle the running process and its removal from the CPU. The process scheduling also manages the selection of an operation by a strategy. It is a necessary and significant component of a multiprogramming operating system. These are the types of the operating systems which are processed to allow the loading of more than one process into the executable memory at the same time. As a result, the CPU uses time multiplexing to be used by these loaded processes.

PROCESS SCHEDULING QUEUES

The operating system maintains the Process Control Blocks in the process of scheduling queues. Every process state gets a separate queue maintained by the operating system. Moreover, there is the availability of PCBs of all the processes in the same state of execution which are placed in the same queue. Every time the state of the process, i.e. from the ready to the waiting state, it experiences PCB unlinking. It is done from its recent queue and then is moved to its new state queue.

The important process of scheduling queues which the OS maintains are as follows

  • Job Queue- Keeping all the processes in the system falls under the job queue.
  • Ready Queue- The set of all the processes which are a part of the main memory, ready and are ready to wait for the execution process to begin is under the ready queue. This queue is never kept empty. Every time there is a new process in it.
  • Device Queue- It contains the processes which are blocked due to the unavailability of the input and output device.

There are different policies for the management of every queue. These are the FIFO, RR- Round Robin, Priority etc. Now the OS scheduler begins the determining work. It decides how to move the processes between the ready and the run queues of the process. Sometimes, it is merged with the CPU. Such processes have only one entry per processor core on the system.

TWO-STATE PROCESS MODEL

Here, the running and the non-running states are the two processes under this model.

Running

Every time there is a new process asking for the processor, it is the running state in which it is found.

Not running

These are the processes which are kept in the waiting state, or the ones which are not in the ready state are constituted under this. They have to wait for their turn during the execution process. In this, the pointer to every process gets queued in the entry. Then the CPU uses the dispatcher. Every entry which is interrupted gets into the waiting queue. The process is discarded only after its abortion or completion. Be it the process completion or the aborted case; the dispatcher selects another process from the queue to be executed.

SCHEDULERS

The special system software which is needed for the management and the handling of the process scheduling in various ways are called schedulers.

The schedulers select the jobs and submit to the system. These jobs decide which process to run. The three types of schedulers are as follows-

  • Long-term scheduler
  • Short-term scheduler
  • Medium-term scheduler

LET US HAVE A LOOK AT THESE THREE IN BRIEF

  1. Long-term scheduler

A long-term scheduler is the one which decodes that which programs are to be chosen for the processing purpose. It is also called a job scheduler and does this by the selecting the processes available in the queue. After this, it loads all the processes into the memory for the execution part and getting the CPU scheduling to be done. Providing a balanced mix of the jobs to the processes is the primary objective of the job scheduler. The tasks include bounding the input and the output and processor bound. Another significant task of the job scheduler is to control the degree of the multiprogramming. Also, keeping the degree of the multiprogramming of the process is also important. It is because, after achieving this stage, keeping the process creation equal to the average rate of departure would be accessible.

It is also possible that all the systems would have a long-term schedule for its processing. They may be absent from it or present in minimal amount. For instance, the time-shared operating systems have no long-term scheduler. It is because that every time there is a change in the state of the process; then there is the need for a long-term scheduler.

  1. Short-term scheduler-

The other name for the short term scheduler is the CPU scheduler. Increasing the performance of the system as per the choice of the criteria set is the primary objective of the CPU scheduler. In simple terms, when the state of the process changes from the ready state to the running state, it is the short-term scheduler. The CPU scheduler performs this by selecting a process from the rest of the available processes and allocating one to the CPU.

They are also called as the dispatchers. They are determined to choose the process to be executed next. Among the both discussed till yet, the short term schedules are faster than the other scheduler.

  1. Medium-term scheduler

We have the medium-term scheduling in swapping. The primary objective here is the removal of the processes from memory. Also, it adds value in reducing the degree of multiprogramming. In-charging the medium-term scheduler and handling the swapped out-processes is the primary objective of the medium-term scheduling.

The main reason for the suspension of the running process is its I/O request. It is obvious that any suspended process can’t make its progression towards the completion. The scheduler moves the suspended process to the secondary storage for the removal of the process from memory and creating space for the other processes. This process is termed as swapping, swapped out. It also has one more name rolled out. The method of swapping out is required for the improvement of the process mix.

 

CONTEXT SWITCH

The mechanism of storing and restoring the context and the state of a CPU in PCB (Process Control Block) is called context switching. It also resumes the execution of the process from the same point later. The main advantage of using the context switching technique is to enable multiple processes for sharing CPU. It is also linked to the multitasking operating system.

But sometimes, we need to avoid the amount of context switching time, that is why some hardware systems two sets of the registers of the processor. The processor needs to store the following information-

  • Program Counter
  • Scheduling information
  • Accounting information

Registers used recently