Page 53 - DCAP103_Principle of operating system
P. 53

Principles of Operating Systems



                   Notes         2.3.1 Scheduling Queues
                                 As processes enter the system, they are put into a job queue. This queue consists of all processes
                                 in the system. 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.
                                 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.
                                 The operating system also has other queues. When a process is allocated the CPU, it executes
                                 for a while and eventually quits, is interrupted, or waits for the occurrence of a particular event,
                                 such as the completion of an I/O request. In the case of a I/O request, such a request may be to a
                                 dedicated tape drive, or to a shared device, such as a 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 processes waiting for a particular I/O device is called a
                                 device queue. Each device has its own device queue (Figure 2.4).


                                              Figure 2.4: The Ready Queue and Various I/O Device Queues


                                             Queue header             PCB,                   PCB,

                                       Ready    Head
                                       queue                         Registers              Registers
                                                Tail



                                        Map     Head
                                        tape
                                        unit 0  Tail


                                        Map     Head
                                        tape                     PCB,          PCB,           PCB,
                                        unit 0  Tail



                                        Disk    Head
                                        unit 0
                                                 Tail
                                                                 PCB,

                                     Terminal   Head
                                       unit 0
                                                 Tail




                                 A common representation of process scheduling is a queueing diagram, such as that in Figure
                                 2.5. Each rectangular box represents a queue. Two types of queues are present—the ready queue
                                 and a set of device queues. The circles represent the resources that serve the queues, and the
                                 arrows indicate the flow of processes in the system.
                                 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 process is assigned to the CPU and is executing, one of
                                 several events could occur:




        46                                LOVELY PROFESSIONAL UNIVERSITY
   48   49   50   51   52   53   54   55   56   57   58