Page 139 - PowerPoint Presentation
P. 139

CAVITE STATE UNIVERSITY
                               T3 CAMPUS
                               Department of Information Technology         ITEC 55 – Platform Technologies

               Non-preemptive Scheduling
                       A scheduling is non-preemptive if, once the CPU has been assigned to a process and
               the process starts executing, the CPU cannot be taken away from that process.
               Following are some of the characteristics of non-preemptive scheduling:
                   1.  In non-preemptive system, short jobs are made to wait by longer jobs but the overall
                       treatment of all processes is fair.
                   2.  In non-preemptive system, response times are more predictable because incoming
                       high priority jobs cannot displace waiting jobs.
                   3.  In  non-preemptive  scheduling,  a  schedular  executes  jobs  in  the  following  two
                       situations:
                          a.  When a process switches from running state to the waiting state.
                          b.  When a process terminates.

               Preemptive Scheduling
                       In preemptive scheduling, even though the CPU has been assigned to a process and
               the process is already executing, the CPU scheduler may decide to assign the CPU to another
               process in the ready queue.
                       The  strategy  of  allowing  processes  that  are  logically  runnable  to  be  temporarily
               suspended  is  called  Preemptive  Scheduling  and  it  is  contrast  to  the  “run  to  completion”
               method.

               First-Come-First-Serve (FCFS) Scheduling
                       It  is  a  non-preemptive scheduling  algorithm  wherein  the one  that  enters  the  ready
               queue first gets to be executed by the CPU first. In choosing the next process to be executed,
               the CPU scheduler selects the process at the front of the ready queue. Processes enter at the
               rear of the ready queue.
                       First-Come-First-Serve algorithm is the simplest scheduling algorithm. Processes are
               dispatched  according  to  their  arrival  time  on  the  ready  queue.  Being  a  non-preemptive
               scheduling, once a process has the CPU, it runs to completion.

                       Let’s take an example of the FCFS scheduling algorithm. In the following schedule,
               there are 5 processes with process ID A, B, C, D and E. A arrives at time 0, B arrives at time
               1, C arrives at time 2, D arrives at time 3, and E arrives at time 4 in the ready queue. The
               processes and their respective Arrival Time and Burst Time are given in the following table.
                       To calculate the completion time, turnaround time, waiting time, average waiting time
               and average turnaround time, use the following formula:

                            Completion Time = Total Amount of time spent by the process
                            Turnaround Time = Completion Time – Arrival Time
                            Waiting Time = Turnaround Time – Burst Time
                            Average Turnaround Time = Sum of Turnaround Tome / No. of Process
                            Average Waiting Time = Sum of Waiting Time / No. of Process

                                                              Completion     Turnaround       Waiting
                 Process ID     Arrival Time   Burst Time
                                                                 Time            Time           Time
                      A              0              2              2              2               0
                      B              1              6              8              7               1
                      C              2              4              12             10              6
                      D              3              9              21             18              9
                      E              4              12             33             29             17

                                          A        B        C        D        E


                                                       Gantt Chart



                                                                                                 Page | 19
   134   135   136   137   138   139   140   141   142   143   144