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
Post a Comment