Page 54 - DCAP103_Principle of operating system
P. 54

Unit 2: Process Management-I



               •  The process could issue an I/O request, and then be placed in an I/O queue.     Notes
               •  The process could create a new sub process and wait for its termination.
               •  The process could be removed forcibly from the CPU, as a result of an interrupt, and be
                 put back in the ready queue.


                      Figure 2.5: Queuing-diagram Representation of Process Scheduling


                         Ready queue                                CPU




                        I/O           I/O queue            I/O request


                                                           Time slice
                                                            expired



                                         Child               Tark a
                                       executos               child


                                       Interrput            Wait for an
                                        occurs               interrupt



            In the first two cases, the process eventually switches from the waiting state to the ready state,
            and is then put back in the ready queue. A process continues this cycle until it terminates, at
            which time it is removed from all queues and has its PCB and resources deallocated.
            2.3.2 Schedulers

            A process migrates between the various scheduling queues throughout its lifetime. The operating
            system must select, for scheduling purposes, processes from these queues in some fashion. The
            selection process is carried out by the appropriate scheduler.
            In  a  batch  system,  often  more  processes  are  submitted  than  can  be  executed  immediately.
            These processes are spooled to a mass-storage device (typically a disk), where they are kept
            for later execution. The long-term scheduler, or job scheduler, selects processes from this pool
            and loads them into memory for execution. The short-term scheduler, or CPU scheduler, selects
            from among the processes that are ready to execute, and allocates the CPU to one of them.
            The primary distinction between these two schedulers is the frequency of their execution. The
            short-term scheduler must select a new process for the CPU frequently. A process may execute
            for only a few milliseconds before waiting for an I/O request. Often, the short-term scheduler
            executes at least once every 100 milliseconds. Because of the brief time between executions, the
            short-term scheduler must be fast. If it takes 10 milliseconds to decide to execute a process for
            100 milliseconds, then 10/(100 + 10) = 9 percent of the CPU is being used (or wasted) simply
            for scheduling the work.
            The long-term scheduler, on the other hand, executes much less frequently. There may be minutes
            between the creation of new processes in the system. The long-term scheduler controls the degree
            of multiprogramming—the number of processes in memory. If the degree of multiprogramming
            is stable, then the average rate of process creation must be equal to the average departure rate



                                             LOVELY PROFESSIONAL UNIVERSITY                                    47
   49   50   51   52   53   54   55   56   57   58   59