Process Scheduling & Queues With Objectives

Process scheduling is a management technique used to manage limited resources when a large number of processes are trying to access them.  For smooth processing and to avoid any deadlocks, process scheduling is an important tool.

This article is all about common types of process scheduling, the most common process scheduling queues, and their objectives. To learn more, let’s start reading ahead.

Process Scheduling

Process scheduling is a practice that is used when there are limited resources and countless processes are struggling for them. Multiprogramming tries to guarantee that there are a few processes running at all times. This is made to make use of the CPU as much as possible.

Advertisement

In a timesharing system, the CPU switches so frequently between jobs that the user does not think that the machine is being shared by many processes or even many users.

process scheduling

If the system has more than one processor, then it is feasible to accomplish more than one process at the same time. In a single process system, only one process can be executed at any specified time. If there are more processes than processors, then the Operating System must list the processes.

It means that some processes will be accomplished and others will have to hang around. There are many strategies for deciding which process should be assigned to the CPU.

Process Scheduling Queues

The most common types of Process scheduling queues and their purpose are as follows:

Job Queue

Each entering process goes into a job queue. The processes in the job queue reside on secondary storage and await the allocation of main memory.

Advertisement

Ready Queue

The set of all processes that are in the main memory and are waiting for CPU time are kept in the ready queue.

Waiting Queue

The set of processes waiting for the allocation of certain I/O devices is kept in the waiting queue.

Process Migration between Various Queues

During its lifetime, a process begins in the job queue. It moves between the ready, waiting, and possibly job queues and eventually finishes the task. This process of moving between various queues is known as process migration.

Scheduler

A process is placed in different scheduling queues throughout its lifetime. The Operating System must select the processes from these queues in some way for scheduling purposes. The part of the Operating System-related to this decision is called the scheduler. The algorithm used by the scheduler is called the scheduling algorithm.

The Operating System must perform three different kinds of process scheduling:

Advertisement
  • Long Term Scheduling
  • Short-Term Scheduling 
  • Mid Term Scheduling

Long Term Scheduling

Long-term scheduler or job scheduler is used to select a job or user program form a job queue to the ready queue in the main memory. The job becomes a process after it has been added to the ready queue in memory.

The long term scheduler controls the number of processes in memory also known as the degree of multiprogramming. The system may slow down if too many processes are loaded into memory. However, too few processes in memory mean that the system is not being utilized efficiently.

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. The long-term scheduler may be invoked only when a process leaves the system. It then decides the next process be executed.

Short-Term Scheduling

The short-term scheduler is also known as the CPU scheduler. It selects a process from the ready queue and allocates CPU to that process for execution.

The short-term scheduler is invoked very frequently and must be very fast. A process is typically allocated to the CPU for a very short period of time. It is moved back to the ready queue after the given time is over. It may be executed only for a few milliseconds.

The short-term scheduler then selects the next process to execute from the ready queue. Thus the short term scheduler makes scheduling decisions much more frequently than the long term and mid-term schedulers.

Medium-Term Scheduling

The medium-term scheduler removes processes temporarily from the main memory and places them on a secondary memory such as a disk drive. It moves it back to main memory when required. It is commonly known as swapping out and swapping in.

The medium-term scheduler may decide to swap out a process that has not been active for some time or it has a low priority. It can also swap out processes. It swaps in the process later when more memory is available or when the process is unblocked and is not waiting for a resource.

It improves the performance of the system by reducing the degree of multiprogramming.

Context Switch

CPU switches from one process to another frequently in multiprogramming systems. The interrupt also causes the CPU to stop the execution of the current process and move to another processor kernel routine. In this situation, the system must save the current context or state of the process being executed.

This information includes the values of CPU registers, process state, and memory management information. It is stored in the process control block. This process of switching from one process to another and saving the state of the current process is known as the context switch.

The kernel saves the context or state of the old process in its PCB and loads the saved context of the new process. It is important for the proper execution of processes. The new process may use the data from the old process if the context switch does not occur.

The CPU does not perform any useful work whenever a context switch is performed. The time required by a context switch depends on the hardware support for the switching such as multiple sets of registers etc.

 

 

 

Related Articles

Leave a Reply

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

Back to top button
Close