Process Scheduling and Scheduling Queues

By | September 13, 2021

Process scheduling

  • Process scheduling is an important activity in multiprogramming environment where several processes run at a time.
  • In multiprogramming, several processes are kept in main memory so that when one process is busy in I/O operation or is waiting for some event to occur, other processes are available to CPU. In such a way CPU is busy in executing processes at all times. As a result CPU utilization is maximized.
  • In uniprogramming environment where only one process is ready for its execution at one moment of time, process scheduling is not required.

Process scheduling consists of the following sub-functions :

1. Scheduling

Selecting the process to be executed next on CPU is called scheduling. In this function a process is taken out from a pool of ready processes and is assigned to CPU. This task is done by a component of OS called scheduler. The scheduling function uses information from the PCBS and selects a process based on the scheduling algorithm being used.

2. Dispatching

Setting up the execution of the selected process on the CPU is called dispatching. It is done by a component of OS called dispatcher. Thus a dispatcher is a program responsible for assigning the CPU to the process that has been selected by the scheduler.

3. Context save

Saving the status of a running process when its execution is to be suspended is known as context save. It usually involves saving the content of various registers into the appropriate fields of the PCB and changing the process state.

Sub-functions in scheduling

The various objectives of scheduling are:

  1. To maximize the system throughput.
  2. To be fair to all users. This does not mean that all users must be treated equally, but consistently, relative to the importance i.e. priority of the work being done.
  3. To provide tolerable response (for online users) or turnaround time (for batch users).
  4. To degrade performance gracefully. If the system becomes overloaded, it should not collapse but avoid further loading (e.g., by inhibiting any new jobs or users) and/or temporarily reduce level of service (e.g. response time).
  5. To be consistent and predictable. The response and turnaround time should be relatively stable.
  6. To enforce priorities. In environments in which processes are given priorities, the scheduling mechanism should favor the higher priority processes

Scheduling Queues

  • In multiprogramming when several processes are in waiting for I/O operation, they form queues.
  • The various queues maintained by operating system are :

1. Job queue

As the process enter the system, it is put into a job queue. This queue consists of all processes in the system.

2. Ready Queue

  • It is a doubly linked list of processes that are residing in the main memory and are ready to run.
  • The various processes in ready queue are placed according to their priority i.e. higher priority process is at the front of the queue.
  • The header of ready queue contains two pointers as shown in figure. The first pointer points to the PCB of first process and the second pointer points to the PCB of last process in the queue.
  • PCB of each process in queue also has a pointer that points to the next process in the ready queue.

Ready Queue

3. Device Queue

  • Device queue contains all those processes that are waiting for a particular I/O device.
  • Each device has its own device queue.
  • Sometimes a process has to wait for its turn in order to get a particular I/O device as other processes may be using that device. In such a situation, a process is blocked due to the unavailability of an input/output device and waits in its device queue.

Leave a Reply

Your email address will not be published. Required fields are marked *