Skip to main content

Process Scheduling

A job’s PCB is created when the Job scheduler accepts the JOB and is updated as the job progress from the beginning to the end of its execution.

Queues use PCBs to track jobs the same way custom officials use passports to track international visitors. The PCB contains all of the data about the job (process) needed by the operating system to manage the processing of the job. As the job moves through the system its progress is noted in the PCB.

Job Queue

As process enters the system, they are put into a job queue. This queue consists of all processes in the system. In this queue all the processes are arranged. Suppose there are five processes than it will be stored in queue like shown in Figure:

FIGURE 2.6 Job queue

Ready Queue

The processes that are residing in main memory and are ready and waiting to execute are kept on a list called the ready queue. This queue is generally stored as a linked list.


FIGURE 2.7 Nodes linked with each other


FIGURE 2.8 Structure of a node

A ready queue header contains pointers to the first and final PCBs in the list. We extend each PCB to include a pointer field that points to the next PCB in the ready queue.




FIGURE 2.9 The ready queue

Here PCB A will store information of process A, also PCB A contains address of PCB B, with the help of address in PCB A, processor will know which process has to be taken next. With the help of pointer processor can fetch the address of next PCB.

Device Queue

The operating system also has other queues. When a process is allocated to CPU, it executes for a while and finally quits, is interrupted, or waits for occurrence of a particular event, such as the completion of an I/O request.

In the case of an I/O request, such a request may be to a dedicated tape drive, or to a shared device, such as disk. Since the system has many processes, the disk may be busy with the I/O request of some other process. The process therefore may have to wait for the disk. The list of processing waiting for a particular I/O device is called a device queue. Each device has its own device queue.

As per diagram shown below, there are six processes, and every two process has some specific I/O request. (A,B) processes have a need of keyboard, so they will be stored in keyboard queue, processes (C,D) has a need of printer, so they will be stored in printer queue, processes (E,F) has a need of disk drive, so they will be stored in disk drive queue.



FIGURE 2.10 Various device queues

Note. In ready queue all the processes will be stored according to the priority levels. Suppose there are 3 processes named A, B, C and they have priority level 2, 1, 3 respectively. So here the processes will be arranged as:


         
FIGURE 2.11 Processes arranged according to priority

A common representation of process scheduling is a queuing diagram. Each rectangular box represents a queue. Two types of queues are present: the ready queue and a set of devices queues. The circle represents the resources that serve the queues.

A new process is initially put in the ready queue. It waits in the ready queue until it is selected for execution (or dispatched). Once the CPU is executing, one of the several events could occur:

·         I/O Request. The process could issue an I/O request and than be placed in an I/O request queue. Suppose there is only device request like printer, than it will be stored in I/O queue. In I/O queue there can be different device queues as we had seen in previous diagram.

·         Fork a child. If the process contains child process than parent process has to wait until the child process completes to execute.

·         Wait for an interrupt. The process could be removed forcibly from the CPU, as a result of interrupt, and be put back in the ready queue. If interrupt is solved than again it will be switched into ready queue.



FIGURE 2.12 Queueing-diagram representation of process scheduling

A process continues this cycle until it terminates at which time is removed from all the queues and has its PCB and resources deallocated.


Compiled By: Chaudhary Amit V. (Resource taken from Galvin) 

Comments

Popular posts from this blog

Characteristics of a Good Programming Language

Till now there are many high level languages which are very popular, and there are others, which could not become so popular in-spite of being very powerful. There might be many reasons for the success of a language, but one obvious reason is the characteristics of the language. Several characteristics believed to be important with respect to making a programming language good are briefly discussed below. Simplicity A good programming language must be simple and easy to learn and use. For example, BASIC is liked by many programmers only because of its simplicity. Thus, a good programming language should provide a programmer with a clear, simple and unified set of concepts which can be easily grasped. It is also easy to develop and implement a compiler or an interpreter for a programming language that is simple. However, the power needed for the language should not be sacrificed for simplicity. The overall simplicity of a programming language strongly affects the readability of the pr...

Angular 4 and Firebase Authentication: Setup

If you have come to this article, it means you are keen to learn new technology and that too Firebase. I love Firebase because it provides all basic but important features of any web application. Take for example, authentication, which is cumbersome and risky if not implemented with utmost care. And when we have the integration of Angular and Firebase, it becomes a lot easier for a developer to build such crucial modules in less time with minimal efforts. In this article we will create a simple Angular application using Firebase. I am going ahead with the understanding that you know the benefits of Firebase and have little knowledge about it. There are plenty of posts out on the web if you are behind. Step 1: Install Angular CLI (if not installed). npm install -g angular-cli Step 2: Create new Angular 4 project. By default now angular CLI will create Angular 4 project so you need not fret. ng new firebase-authentication Step 3: Check whether the ne...

Switch-case, simple calculator . . .

11.      Write a program to perform some mathematic functions with the help of “switch-case” statement. #include<stdio.h> #include<conio.h> void main() { int a,b,ans; char c; clrscr(); printf("\ Enter a and b:"); scanf("%d%d",&a,&b); printf("\n Enter operator:"); fflush(stdin); scanf("%c",&c); switch(c) { case'+':ans=a+b;       break; case'-':ans=a-b;       break; case'*':ans=a*b;       break; case'/':ans=a/b;       break; } printf("\n ans %d",ans); getch(); } 12.      Print the Fibonacci series #include<stdio.h> #include<conio.h> void main() { int a=1,b=1,s=3,c,ch; clrscr(); printf("how many steps="); scanf("%d",&ch); printf("%5d%5d",a,b); for(s=3;s<=ch;s++) {       c=a+b;       printf("%5d",c);       a=b;    ...