Computer Operating Systems: Process Scheduling

In this article we will learn the concept of process scheduling. In order to understand the same, we will also get into the details of scheduling queues, schedulers and lastly context switch. These altogether would serve as an important link to understand the working of modern day processors.

In an earlier article, we learned the concepts of process and thread in efficient computing. The different states of a process and the function of a process control block were also discussed. One thing that often lingers in our mind is that what is the need for multi-programing because when we are working on the system we are basically addressing only a single program at a time. The reason behind this is to keep some process running at all times so that the CPU utilization is maximized. Time sharing plays a major role in multi-programming as it helps the CPU to switch among the programs faster which in turn helps the user interact with each and every program during its run time. A process scheduler is used to select the particular process to be sent to the CPU for execution. In case its a single-processor system, all the other processes have to wait till the completion of the previous process.


Scheduling Queues

Once a process enters the system it is put into a queue known as the job queue. The queue consists of all the processes in the system. When the process enters the main memory and is ready to be executed its put into another queue known as the ready queue, which has all the processes which are waiting for execution. These queues are mostly stored as linked list. The ready-queue header has pointers which point to the first and final PCB in the list, moreover every PCB has a pointer field which points to the upcoming PCB in queue.

While execution of a process it may make an I/O request to a shared device, but the particular device may be busy responding to some earlier requests. To solve such issues there exists a device queue that has a list of all the processes that are waiting for a given device. This queue is present in every single I/O device. A queuing diagram is used to demonstrate the flow of events by the use of arrows which point to the next queue to be addressed.

As already mentioned, a new process is sent to the ready queue and it waits for execution till it is finally dispatched. Once a given process is allocated, one of the following situations may arise:

  • Process makes a request to some I/O device and hence is put in the respective device queue.

  • The process can also generate a sub-process and wait till its termination before proceeding further.

  • Situations may arise when the process is forcibly removed from the CPU and placed in the ready queue. This usually occurs due to an interrupt.

Of the above mentioned situations, in the first two the process switches to waiting state and then back to the ready state. This cycle keeps going on till the process is terminated, after which the PCB and resources are deallocated.



These are used to select the process to be dispatched next based on different parameters. Generally a lot more processes are submitted in comparison to the maximum number that can be executed at a time and are hence stacked up in a queue. There are two types of schedulers, one is the long-term scheduler and the other is short-term scheduler. The earlier one is used to pick the process from the secondary memory and place it in the primary memory into the ready queue whereas the later one selects the process from the ready queue so that it can be sent for execution.

The main difference between the two schedulers is their frequency. The short-term scheduler needs to be fast as a process does not take much long before calling for an interrupt. Due to this the scheduler needs to shift processes almost every 100 milliseconds. The long-term scheduler has much lower frequency and is the key controller of the degree of multi-programming. It is said to be stable if the average number of processes created equates the number of processes leaving the system in a given time duration. So it is clear that the long-term scheduler is put to use only when a process is completed and hence it takes longer time to select the next process for execution.

The available processes can be divided into two types based on their behavior. I/O bound processes are those which spend more time in doing i/O rather than computations while CPU-bound processes are those which spend most of the time doing computations rather than I/O. It is important that the long-term scheduler selects the proper mix of processes since otherwise an imbalance may take place. If more of I/O-bound processes are chosen then the ready queue would be empty most of the time and short-term scheduler would have nothing to do. On the other hand if all are CPU-bound processes then the devices would remain unused and the I/O waiting queue would be empty. Thus to avoid such imbalance a proper combination of both processes is required.

The presence of these two schedulers is not mandatory. Some systems may exist which don't have the long-term scheduler and the newly added processes are directly put into the ready queue so that it can be selected by the short-term scheduler. The proper functioning of such system depends on the physical limitation and self-adjusting nature of human users. Some systems may also exist which have the medium-term scheduler whose job is to remove some process from the memory and reintroduce them later in order to reduce the pressure of multi-programming. This process of removal and addition is known as swapping and the given actions are specified as swap out and swap in respectively.

Context Switch

When an interrupt occurs its necessary for the CPU to store the present context of the process so that later these details could be used during the remaining execution. The context is represented in the PCB of the process and stores details of the registers, process sate and memory-management information. So it is basically the state save of the current state of the process followed by state restore when further execution takes place. This process of state save and state restore is known as context switching. Its time is pure overhead since nothing beneficial is being done. The speed depends on architecture, the instructions being transferred and the number of registers being copied.

Related Articles

Buying Guide: How To Select A Computer?

Which computing device are you planning to buy? The more than a half dozen of computers available in the market such as tablets, all in ones, desktop, note or ultrabook have turn the confusion worse compounded as to which one to buy and which not. Don’t make haste!. Know before buying which computer would suit you the best. Just read this article to have some inkling of the idea needed before zeroing on a computer.

Computer and Laptop Security Tips

In this resource we are going to have a discussion on the ideas and ways out to safeguard our System and Laptops. There are some additional powerful tips for the laptop security in the end. In order to have a clear cut idea that what is actually the difference between malware, spyware and other security threats, kindly have a look at the resource in detail.

Changing Power Options in Your Computer

Imagine a scenario wherein a user has to switch off the system temporarily, but he/she doesn’t even have the time to save the program/application on which he/she is working. If the user is aware of the various power options available with Windows, he will definitely use them during such scenarios. This article informs change the power options in the computer.

How To Buy A Computer Carefully?

This article gives complete information on buy a computer carefully considering various things. One can either buy an assembled or branded computer according to one's choice and suitability. It also explains about the details of computer accessories like the processor, mother board, ram, hard disk, video writer, monitor, smps etc along with their price for better understand ability of the readers.

Computers - changing the world

Today computers are become the essence of our life and it create the huge impact to the world. We can do our work in a proper and effective manner. This is the best invention of science and technology.

More articles: Computer


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: