Page 85 - DCAP403_Operating System
P. 85

Operating System




                    Notes                                     Figure 5.4: Priority Scheduling


                                       Flow 1

                                       Flow 2             Classifier  Highest Priority

                                                                                          Scheduler
                                       Flow 3
                                                                                                    Port
                                                                       Middle Priority
                                       Flow 4
                                       Flow 5
                                                                       Lowest Priority
                                       Flow 6

                                       Flow 7

                                       Flow 8



                                   Advantages and Disadvantages


                                   The main advantage is the important jobs can be finished earlier as much as possible. The main
                                   disadvantage is the lower priority jobs will starve.

                                          Example:

                                          Process          Burst time           Arrival            Priority
                                           P                  10                  0                  3
                                            1
                                           P 2                 1                  0                  1
                                           P 3                 2                  0                  4
                                           P                   1                  0                  5
                                            4
                                           P                   5                  0                  2
                                            5
                                   Gantt Chart


                                                       P 2     P 5       P 1     P 3    P 4
                                                     0     1        6         16     18    19

                                   Average waiting time: (0+1+6+16+18)/5 = 8.2

                                   5.3.5 Round-Robin (RR)

                                   Round-robin scheduling is really the easiest way of scheduling. All processes form a circular
                                   array and the scheduler gives control to each process at a time. It is off course very easy to
                                   implement and causes almost no overhead, when compared to all other algorithms. But response
                                   time is very low for the processes that need it. Of course it is not the algorithm I want, but it can
                                   be used eventually.
                                   This algorithm is not the best at all for general-purpose Operating Systems, but it is useful for bath-
                                   processing Operating Systems, in which all jobs have the same priority, and in which response
                                   time is of minor or no importance. And this priority leads us to the next way of scheduling.


          78                               LOVELY PROFESSIONAL UNIVERSITY
   80   81   82   83   84   85   86   87   88   89   90