Docstoc

An Efficient SJRR CPU Scheduling Algorithm - PDF

Document Sample
An Efficient SJRR CPU Scheduling Algorithm - PDF Powered By Docstoc
					                                                                 (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                           Vol. 8, No. 2, 2010

         An Efficient SJRR CPU Scheduling Algorithm

     Saeeda Bibi 1, Farooque Azam1, Sameera Amjad1, Wasi Haider Butt1,Hina Gull1, Rashid Ahmed1,Yasir
                                              Chaudhry 2
                                                1
                                            Department of Computer Engineering
                                  College of Electrical and Mechanical Engineering, NUST
                                                     Rawalpindi, Pakistan
                                             2
                                               Department of Computer Science
                                             Maharishi University of Management
                                                     Fairfield,Iowa USA
      {saeedabb, sameerashaheen, butt.wasi, hinagull03, yasiryc }@gmail.com, farooq {farooq , rashid}@ceme.nust.edu.pk


Abstract— CPU Scheduling is a vital discipline which helps us                     Scheduling Algorithms can be broadly classified into
gain deep insight into the complex set of policies and mechanisms             preemptive and non-preemptive scheduling disciplines. The
used to govern the order in which tasks are executed by the                   algorithm proposed in this article is preemptive in nature and
processor. This article proposes an efficient Shortest Job Round              attempts to give fair CPU execution time by focusing on
Robin (SJRR) CPU Scheduling algorithm having better average                   average waiting time and turnaround time of a process. This
waiting time (AWT) and average turnaround time (ATT) as                       article comprises of the following sections: Section 2 presents
compared to other CPU Scheduling techniques. The primary                      scheduling parameters which will decide against which
objective of this algorithm is to optimize system performance                 parameters the new CPU scheduling algorithm will be tested.
according to the criteria deemed most important by system                     Section 3 introduces existing scheduling algorithm. Section 4
designers. Included in this work, is a simulation that compares
                                                                              explains the SJRR scheduling algorithm. Section 5 contains
the proposed algorithms with some well known practices to CPU
scheduling.                                                                   pseudocode of the algorithm. Section 6 explains the two basic
                                                                              elements that make up the simulation and provide an
   Keywords-component; First Come First Serve Algorithm,                      interactive user interface. Section 7 presents a graphical
Shortest Job First Algorithm, Round Robin Algorithm, Priority                 comparison of the new algorithm with existing techniques. Last
Algorithm, Average Waiting Time, Turnaround Time, Response                    but not the least Section 8 will provide conclusion of the
Time, Throughput                                                              work...

                        I.   INTRODUCTION                                                      II. SCHEDULING PARAMETERS
    Scheduling is a technique which involves complex set of                        Different    scheduling    algorithms have     different
policies and mechanisms working at the back of a processor,                   characteristics which decide selection of processes using
instructing it the order in which it should execute a given set of            different criteria for execution by CPU. The criteria which
processes. Process is a smallest work unit of a program which                 decide how one algorithm differs from the other have been
requires a set of resources for its execution that are allotted to it         listed below:
by the CPU. These processes are many in number and keep
                                                                              A. Processor utilization
coming in the queue one after the other. In order to execute
them in a particular fashion, different scheduling techniques are                 It is the average fraction of time during which the processor
employed that enable faster and efficient process execution                   is busy [2]. Being busy means the processor is not idle.
thereby reducing the waiting time faced by each process and
increasing CPU utilization. A process has five basic states                   B. Throughput
namely New, Ready, Running, Waiting and Terminate [1] [5].                         It refers to the amount of work completed in a unit of time
    Throughout its lifetime a process migrates between various                [2]. That is, the number of user jobs executed in a unit of time.
scheduling queues by different schedulers until it gets                       The more the number of jobs, the more work is done by the
terminated. These queues mainly contain the ready queue                       system.
which contains set of processes ready for CPU response. The                   C. Turnaround Time
second queue is the device or the I/O queue which contains all
the processes that are waiting for I/O response [1]. The                           It is defined as the time taken to execute a given process
operating system must select processes for scheduling from                    [1]. That is, it is the time spends by the process in the system
these queues in a specific manner. This selection process using               from the time of its submission until its completion by the
a particular scheduling technique is carried out by schedulers.               system.
Schedulers in general try to maximize the average performance
of a system according to the given criterion [2].




                                                                        222                              http://sites.google.com/site/ijcsis/
                                                                                                         ISSN 1947-5500
                                                              (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                        Vol. 8, No. 2, 2010
D. Waiting Time                                                            makes the user feels processor sharing between multiple
                                                                           processes very fast. Average waiting time is high because of
   Scheduling algorithms do not affect the amount of time                  FCFS policy and context switching [1].
during which a process executes or does I/O, it affects only the
amount of time spend by the process in the ready queue [1].
That is, the amount of time spent in the ready queue by the                D. Priority Based Scheduling
process a waiting CPU execution.                                                Priority scheduling executes processes based on their
                                                                           priority which may be assigned by the system or by the user
E.   Response Time:                                                        himself [3]. Processes with the high priority are executed first
   While turnaround time includes total time taken by the                  and those with low priorities are executed next [6]. Processes
process from the time of its submission until the time of its              with equal priority values are executed using FCFS approach
completion, response time is the measure of time from the                  [1].
submission of requests until the first response is produced [1].
This response time does not include the time taken to output               E. Multilevel Queues (MLQ) Scheduling
that response.                                                                 It is a complex scheduling technique in which workload is
                                                                           divided among multiple queues employing different schedulers
       III.   OVERVIEW OF E XISTING CPU SCHEDULING                         on different queues. Division of workload might be classified
                       ALGORITHMS                                          as system processes, interactive programs, batch jobs etc [2].
                                                                           Each high priority queue contains foreground processes which
   CPU scheduling algorithms aim at deciding which                         have priority over lower priority queues which contain
processes in the ready queue are to be allotted to the CPU.                background processes. Processes keep moving between these
Discussed in this section are some common CPU scheduling                   queues depending on the scheduler employed on the particular
algorithms                                                                 queue [1].
A. First Come First Served (FCFS) Scheduling
    FCFS employs the simplest scheduling technique on the                             IV. SJRR CPU SCHEDULING ALGORITHM
basis of first come first served. The work load is processed in                Shortest Job Round Robin (SJRR) is preemptive in nature.
the order of arrival, with no preemption [2]. Once a process has           It sorts all incoming processes based on their burst time in
been submitted to the CPU, it runs into completion without                 ascending order in the ready queue. Next it uses the time
being interrupted. Such a technique is fair in the case of smaller         quantum to execute processes. If time quantum expires before
processes but is quite unfair for long an unimportant job [3].             the process execution then CPU is preempted and given to the
Since FCFS does not involve context switching therefore it has             next shorter waiting process in the queue. The preempted
minimal overhead. It has low throughput since long processes               process is then placed at the end of the ready queue. The
can keep processor occupied for a long time making small                   average waiting time and average turnaround time obtained
processes suffer. As a result waiting time, turnaround time and            from SJRR is better than existing CPU scheduling algorithms.
response time can be low [4].
                                                                               SJRR is fair in scheduling and effective in time sharing
                                                                           environment. In SJRR scheduling, CPU is given to each
B. Shortest Job First (SJF) Scheduling                                     process for equal time period, no process has to wait for long
    Shortest Job First is non-preemptive in nature in which                time for the CPU. The explicit working of the SJRR algorithm
process with smallest estimated run time to completion is                  is discussed below:
executed next. SJF reduces average waiting time of processes
as compared to FCFS. SJF favors shorter processes over longer
ones which is an overhead as compared to FCFS [6]. It selects                    Take list of processes, their burst time, arrival time and
the job with the smallest burst time ensuing CPU availability                     time quantum.
for other processes as soon as the current process reaches its                   Arrange processes and their relative burst time in
completion.
                                                                                  ascending order using any sorting technique.
    This prevents smaller processes from suffering behind
larger processes in the ready queue for a long time [3] [7].                     Iterate through the given list of processes to find the
                                                                                  processes having maximum burst time and initialize
C. Round Robin (RR) Scheduling                                                    waiting time of each process with zero.
    Round Robin is preemptive in nature. It employs FCFS for                     If number of processes are odd then
process execution by assigning a quantum or time slice to each
process [7]. As soon as the quantum expires control is                                   o   Take burst time of the middle process and
forcefully taken from the current process under execution and                                assign this value to the time quantum
is transferred to the next in the queue for the same period of                   Else
time slice [3]. The outcome of RR algorithm in term of
performance depends entirely on the size of time quantum. If                             o   Take the average of burst time of two middle
the quantum is very large, RR algorithm works the same as the                                most processes and assign this value to the
FCFS algorithm. If the quantum is very small, RR algorithm                                   time quantum




                                                                     223                               http://sites.google.com/site/ijcsis/
                                                                                                       ISSN 1947-5500
                                                             (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                       Vol. 8, No. 2, 2010
                                                                                                                       burst             time
                                                                                                                       completed.
   Find maximum number of time each process will                            Iterate through the list of processes
    execute by dividing maximum burst time with time                               o Add total waiting time with waiting time of
    quantum then add one in the result.                                                 each process to find total waiting time
   Initialize an array with zero that is used for storing the                     o Add burst time and waiting time of each
                                                                                        process to find turnaround time
    burst time that has been completed.
                                                                                   o Add total turnaround time and turnaround
   Iterate through the given list of processes.                                        time of each process to find total turnaround
                                                                                        time
        o    Initialize a variable with zero that is used as a               Average waiting time is calculated by diving total
             counter.                                                         waiting time with total number of processes.
        o    Iterate until the burst time of the process is                  Average turnaround time is calculated by dividing total
             greater than zero.                                               turnaround time with total number of processes.

        o    If burst time is greater than or equal to time
             quantum then                                                                    V.    PSEUDO CODE
                       Store remaining burst time                     burst  0
                                                                       max  0
                       Store completed burst time                     temp  0
                       Increment counter                              total_tatime  0.0
                                                                       tw_time  0.0
        o    Else                                                      avg_wt  0.0
                                                                       avg_tatime 0.0
                       Store completed burst time
                       Assign zero to burst time variable             For i  process-1 to 0
                                                                             For j  1 to process
                       Increment counter
                                                                                 IF btime[j-1] > btime[j]
        o    Assign value of counter minus one in counter                            temp  btime[j-1]
             array                                                                   btime[j-1]  btime[j]
                                                                                     btime[j]  temp
   Iterate through the list of processes                                             ptemp  proname[j-1]
         o    Iterate through the length of counter array                             proname[j-1]  proname [j]
                    If value of variable used for counter                             proname[j]  ptemp
                        is equal to the counter of processes
                                                                       For i  0 to process
                        then                                                 btime[i]  bu[i]
                              Iterate through the process                   proname[i]  pname[i]
                                 coming from the list of                     IF max < btime[i]
                                 processes                                       max  btime[i]
                              If value of that process is                  b[i]  btime[i
                                                                            wtime[i]  0
                                 not equal to the upcoming
                                 process then                          IF process%2!=0
                                      o    Add the waiting                      mid (process+1)/2
                                          time     of      the                  t btime[mid]
                                          upcoming process             ELSE
                                          with the burst time                   mid  process/2
                                          completed.                            t (btime[mid]+btime[mid+1])/2
                    Else
                                                                       dim  max/t + 1
                              Iterate through the list of
                                 processes
                              If that process is not equal            For i 0 to process
                                 to the upcoming process                     For j  0 to dim
                                 then                                           r [i,j]  0
                                      o Add waiting time
                                          of the upcoming
                                          process with the



                                                                 224                              http://sites.google.com/site/ijcsis/
                                                                                                  ISSN 1947-5500
                                                          (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                    Vol. 8, No. 2, 2010
For i  0 to process
    j 0                                                                 1) First Screen Interface
    While btime[i]>0
          IF btime[i] >=t
              btime[i] btime[i]-t
              r[i,j]  t
              j  j+1

           ELSE
             r[i,j]  btime[i]
             btime[i]  0
             jj+1
counter[i]  j-1

For j 0 to process
     For i  0 to counter [j]
         IF i = = counter[j]
            For k 0 to j
                 IF k != j
                     wtime[j]  wtime[j] + r[k,i]

         ELSE
           For k o to process
               IF k != j                                                                   Snapshot 1: First Screen Interface
                   wtime[j]  wtime[j] +r[k, i]
                                                                         The Snapshot 1 of the parent screen illustrated above
For j 0 to process                                                    contains two drop down lists namely ‘First Algo’ and ‘Second
      tw_time  tw_time + wtime[j]                                     Algo’, one for each algorithm respectively. Two algorithm
      tatime[j]  b[j] + wtime[j]                                      choices are entered by the users that are to be compared. After
      total_ tatime  total_tatime+ tatime[j]                          choosing two algorithms the user then clicks the ‘New’ option.
                                                                       This selection is depicted below in Snapshots 2 & 3. These
                                                                       Snapshots illustrate how choices are entered and the selection
avg_wt  tw_time / process
                                                                       choices are available. Same choice of algorithms in both
avg_tatime  total_tatime/ process                                     dropdown lists is restricted.

                  VI.   SIMULATION DESIGN
   The simulation provides an interactive GUI interface to the
user through which a user can input data related to different
processes then applying different algorithms based on the
algorithm choices given in the simulator. The simulator
employs .NET framework using C# on the front end and
Microsoft Access for database at back end. Both front end and
back end features are discussed below:

A. Front End Features
   The front end of the simulator has been built on .Net
framework using C# as the coding language. It comprises of
one parent screen and two child screens. The parent screen or
the main window provides interactive GUI to the user which is
used to choose two algorithms from the drop down list that are
to be compared.




                                                                              Snapshot 2: First Screen Interface with selection of First Algo




                                                                 225                                  http://sites.google.com/site/ijcsis/
                                                                                                      ISSN 1947-5500
                                                                         (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                                   Vol. 8, No. 2, 2010




                                                                                                     Snapshot 5: Second Screen Interface

                                                                                      After giving input for each process in the process set, then
                                                                                   click the ‘Add’ option in the menu bar provided in the screen.
      Snapshot 3: First Screen Interface with selection of Second Algo
                                                                                   Keep adding the processes and their specifics until all desired
                                                                                   processes have been entered. After this close this screen which
   Whenever in anyone of the given dropdown list, if Round                         transfer the control to the first screen. Here, the user then
Robin algorithm get selected another window pops up. This                          clicks the ‘Schedule’ button which will apply the chosen
window is the Time Quantum Screen which will ask the user                          algorithm techniques on the same process set separately. The
to enter the desired time quantum for the process set. All the                     first panel given at the bottom of the First Screen shows the
processes will apply the same time quantum on all the                              Gantt chart results for the first algorithm that was entered
processes for Round Robin algorithm.                                               while the second panel shows the Gantt chart results of the
                                                                                   second algorithm.




                   Snapshot 4: Time Quantum Screen

  2) Second Screen Interface
  This screen will open when ‘New’ option is clicked. It
enables the users to enter the process set containing different
processes each having its own specific process name, arrival
time, burst time and priority. This set is used by both the
chosen algorithms for applying their own techniques on the
same process set. Given below is a snapshot which depicts                                        Snapshot 6: First Screen with Gantt Chart
this input in take.




                                                                             226                                http://sites.google.com/site/ijcsis/
                                                                                                                ISSN 1947-5500
                                                             (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                       Vol. 8, No. 2, 2010
B. Back End Features                                                      difference between average waiting time (AWT) of FCFS and
   Microsoft Access is employed at the back end which stores              SJRR is quite large which makes SJRR an efficient algorithm
the processes, their arrival time, burst time and priorities              with respect to the average waiting time. Same behavior was
                                                                          observed in the graph given in Figure 2, when average
entered by the user. The data field name and the data type
                                                                          turnaround times (ATT) of the two algorithms were compared.
used for storing and manipulating these values include:
                                                                          The difference between the two plots, that is, plot of AWT and
                                                                          ATT; are quite negligible with small set of processes but the
           ID = Auto number                                              difference becomes noticeable when the set of processes grow
           Process = Text                                                large. Hence SJRR has better AWT and ATT readings as
           Arrival Time = Number                                         compared to FCFS.
           Burst Time = Number
           Priority = Number                                                                                             Com parison of avg. w aiting tim e of FCFS and SJRR
                                                                                                                                    CPU Scheduling Algorithm s
   The ID number will be generated by the database at random                                                         8000




                                                                                             Average Waiting Time
                                                                                                                                                                                        FCFS
as the processes get entered. The next data field is the Process                                                     6000                                                               SJRR
name which can contain any string as named by the user. The
Arrival Time takes numeric values for recording the arrival                                                          4000
time of the processes. The Burst Time is the time which the                                                          2000
process needs from the CPU for the completion of its task and                                                              0
has numeric data type. The priority of processes is also                                                                            5      10      15      20        25    30
numeric which stores values and decide the priority of each                                                                                        Processes
process entered.

                                                                                                                     Figure 1: AWT of FCFS & SJRR Scheduling Algorithms


                                                                                                                                   Com parison of Tur naround Tim e of FCFS and SJRR


                                                                                                               8000
                                                                                                               7000
                                                                                Avg Turnaround Time




                                                                                                               6000
                                                                                                               5000
                                                                                                                                                                                         FCFS
                                                                                                               4000
                                                                                                                                                                                         SJRR
                                                                                                               3000
                                                                                                               2000
                                                                                                               1000
                                                                                                                      0
                                                                                                                               5           10        15         20        25       30
                     Snapshot 7: Database Screen                                                                                                       Processes




       VII. COMPARISON OF SJRR WITH OTHER CPU
           SCHEDULING ALGORITHMS AND RESULTS
                                                                                                                    Figure 2: ATT of FCFS & SJRR Scheduling Algorithms
    To compare the performance of SJRR, it was implemented
with some other existing CPU scheduling algorithms. By                    B. Comparison of SJRR with SJF
taking lists of processes, processes are scheduled using
different CPU scheduling algorithms. Average waiting time                     Along the x-axis we have different set of processes that
and average turnaround time was noted down for each. Results              were chosen for SJRR and SJF scheduling algorithms. Along
of average waiting time and average turnaround time for each              y-axis we have the average waiting time and average turn
algorithm are illustrated in the graphs below which depict                around time spend by these set of processes while using these
behavior of each algorithm against others using a specific set of         two scheduling approaches as given in Figure 3 and Figure 4
processes which random quantum size used per process set.                 respectively. As depicted in the graphs given below, the AWT
                                                                          and ATT of SJRR was greater than AWT and ATT of SJF.
A. Comparison of SJRR with FCFS                                           SJRR showed negligible difference with SJF for small number
    Along the x-axis we have different set of processes that              of processes. But this difference starts becoming noticeable
were chosen for SJRR and FCFS scheduling algorithms. Along                when set of processes grow above 20 processes.
y-axis we have the average waiting time and average turn
around time spend by these set of processes while using these
two scheduling approaches as given in Figure 1 and Figure 2
respectively. As depicted in the graph given in Figure 1, the




                                                                    227                                                                            http://sites.google.com/site/ijcsis/
                                                                                                                                                   ISSN 1947-5500
                                                                                                    (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                                                              Vol. 8, No. 2, 2010

                                  Comparison of avg. w aiting tim e of SJF and SJRR CPU                                                                                   Comparison of avg. waiting time of RR and SJRR CPU
                                                Scheduling Algorithm                                                                                                                    Scheduling Algorithms


                               8000                                                                                                                                     10000
        Average Waiting Time




                                                                                                                                                 Average Waiting Time
                               6000                                                                                                                                     8000
                                                                                             SJF                                                                        6000                                                                   RR
                               4000
                                                                                             SJRR                                                                       4000                                                                   SJRR
                               2000
                                                                                                                                                                        2000
                                      0                                                                                                                                      0
                                                5    10      15      20      25      30                                                                                               5        10      15        20        25    30
                                                             Processes                                                                                                                                 Proces ses


                                                                                                                                                                            Figure 5: AWT of RR & SJRR Scheduling Algorithms
                                      Figure 3: AWT of SJF & SJRR Scheduling Algorithms

                                                                                                                                                                                     Com parison of Turnaround Tim e of RR and SJRR


                                          Com paris on of Turnaround Tim e of SJF and SJRR                                                                          10000
                                                                                                                                                                     9000
                                                                                                                                                                     8000




                                                                                                                                       Avg. Turnaround Time
                               7000
                                                                                                                                                                     7000
                               6000                                                                                                                                  6000
                                                                                                                                                                                                                                                 RR
    Avg. Turnaround Time




                               5000                                                                                                                                  5000
                                                                                                                                                                                                                                                 SJRR
                                                                                                                                                                     4000
                               4000                                                          SJF                                                                     3000
                                                                                             SJRR                                                                    2000
                               3000
                                                                                                                                                                     1000
                               2000                                                                                                                                     0
                               1000
                                                                                                                                                                                 5          10         15        20         25        30
                                                                                                                                                                                                        Processes
                                  0
                                            5       10      15       20       25       30
                                                             Processes                                                                                                      Figure 6: ATT of RR & SJRR Scheduling Algorithms


                                      Figure 4: ATT of SJF & SJRR Scheduling Algorithms
                                                                                                              D. Comparison of SJRR with Priority
                                                                                                                  Along the x-axis we have different set of processes that
                                                                                                              were chosen for SJRR and Priority scheduling algorithms.
C. Comparison of SJRR with RR
                                                                                                              Along y-axis we have the average waiting time and average
    Along the x-axis we have different set of processes that                                                  turn around time spend by these set of processes while using
were chosen for SJRR and RR scheduling algorithms. Along                                                      these two scheduling approaches as given in Figure 7 and
y-axis we have the average waiting time and average                                                           Figure 8 respectively. As shown in the graphs SJRR shows
turnaround time spend by these set of processes while using                                                   better readings of AWT and ATT as compared to Priority.
these two scheduling approaches as given in Figure 5 and                                                      There is a small difference between the results of AWT and
Figure 6 respectively. SJRR shows negligible difference with                                                  ATT of SJRR and the results of AWT and ATT of Priority.
AWT and ATT of RR when the set of processes is small. RR
gave better AWT and ATT readings when time quantum was                                                                                                                  Comparison of avg. waiting time of Priority and SJRR
small for a set of processes. But SJRR produced much better                                                                                                                        CPU Scheduling Algorithm
AWT and ATT results as compared to RR when the time
quantum was increased. That is, for large quantum size, SJRR                                                                                         7000
                                                                                                                Average Waiting Time




gives much better results as compared to RR.                                                                                                         6000
                                                                                                                                                     5000
                                                                                                                                                     4000                                                                                  Priority
                                                                                                                                                     3000                                                                                  SJRR
                                                                                                                                                     2000
                                                                                                                                                     1000
                                                                                                                                                        0
                                                                                                                                                                                 5        10     15         20        25    30
                                                                                                                                                                                                    Processes


                                                                                                                                                                         Figure 7: AWT of Priority & SJRR Scheduling Algorithms




                                                                                                        228                                                                                          http://sites.google.com/site/ijcsis/
                                                                                                                                                                                                     ISSN 1947-5500
                                                                                                            (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                                                                      Vol. 8, No. 2, 2010

                                          Com parison of Turnaround Tim e of Priority and SJRR
                                                                                                                           Processes                                                FCFS                   SJF                 RR               Priority          SJRR
                           8000                                                                                                                                     5                40.2                  25.2               35.2                    45              27.2
                           7000
                                                                                                                                                                   10                87.4                  69.5              104.5               102.3                86.5
    Avg. Turnaround Time




                           6000
                           5000
                                                                                                 Priority                                                          15               299.5              252.73                362.07              305.5                305.9
                           4000
                                                                                                 SJRR                                                              20               196.85              172.8                244.15              225.2                205.2
                           3000
                           2000                                                                                                                                    25               3254                   2358              4013.2              3388             2974.4
                           1000
                             0
                                                                                                                                                                   30               6999                   4960              8581                6893             6587.5
                                      5          10        15        20          25       30
                                                             Processes
                                                                                                                                                                   Table 2: Experimental Results for Average Turnaround Time

                             Figure 8: ATT of Priority & SJRR Scheduling Algorithms                                       Below is the graphical depiction of Table 1 and Table 2.
                                                                                                                      Figure 9 illustrates cumulative comparison of AWT of SJRR
                                                                                                                      with AWT of FCFS, SJF, RR and Priority scheduling
E. Comparative Analysis of Above CPU Scheduling
                                                                                                                      algorithms. Figure 10 illustrates cumulative comparison of
    Algorithms
                                                                                                                      ATT of SJRR with FCFS, SJF, RR and Priority scheduling
    Waiting time and Turn Around time are some of the                                                                 algorithms. Analysis of both plots show that AWT and ATT of
factors that can be used to check efficiency of a CPU                                                                 SJRR is better than AWT and ATT of FCFS, RR and Priority
Scheduling algorithm. Waiting time gives the amount of time                                                           but SJRR shows an increase in AWT and ATT as compared to
a process has spent in the ready queue waiting CPU execution.                                                         that of SJF. Using these analysis results it is concluded that
The more the time spent by a process in the ready queue the                                                           SJRR show a marked improvement in AWT and ATT
more time will be taken by the CPU to execute processes                                                               perspectives as compared to those of FCFS, RR and Priority
queued behind that process which will retard CPU efficiency.                                                          scheduling algorithms.
Similarly turn around time is the amount of time taken by a
CPU to execute a process. The more this time is taken the                                                                                                                        Comparison of Avg Waiting Tim e of CPU Scheduling Algorithms
slower the CPU gets making other processes starve infinitely.
                                                                                                                                                              9000
                                                                                                                                                              8000
    To check the performance of proposed algorithm, i.e.                                                                                                      7000
                                                                                                                            A v e r a g e W a itin g T im e




                                                                                                                                                                                                                                                           FCFS
SJRR, we took six process sets, each with different                                                                                                           6000
                                                                                                                                                                                                                                                           SJF
characteristics and made comparisons of these. First process                                                                                                  5000
                                                                                                                                                                                                                                                           RR
set contains 5 processes, second set contains 10 processes,                                                                                                   4000
                                                                                                                                                                                                                                                           Priority
                                                                                                                                                              3000
third set contains 15 processes, fourth set contains 20                                                                                                       2000
                                                                                                                                                                                                                                                           SJRR
processes, fifth set contains 25 and sixth set contains 30                                                                                                    1000
processes. Each process has its own specific CPU burst time,                                                                                                     0
                                                                                                                                                                            5          10             15               20          25            30
arrival time, priority number and time quantum.                                                                                                                                                            Processes
    Performance metrics for the CPU scheduling algorithms
are based on two main factors – Average Waiting Time and
Average Turnaround Time. Table 1 shows the Average                                                                         Figure 9: Average Waiting Time of CPU Scheduling Algorithms
                                                                                                                                              (Comparative Analysis)
Waiting Time for each process set and Table 2 shows the
Average Turnaround Time for each process set.                                                                                                                               Com parison of Turnaround Tim e of CPU Schduling Algorithm


                                                                                                                                                                   10000
                                                                                                                                                                    9000
                                                                                                                                                                    8000
                                                                                                                                            Avg. Turnaround Time




                    Processes                FCFS           SJF            RR         Priority   SJRR                                                               7000                                                                                    FCFS
                                                                                                                                                                    6000                                                                                    SJF
                              5                28            13            23            32.8      15                                                               5000                                                                                    RR
                                                                                                                                                                    4000                                                                                    Priority
                             10               69.1          51.2           86.2           84      68.2                                                              3000                                                                                    SJRR
                                                                                                                                                                    2000
                             15             260.47        213.67           323         266.47    266.8                                                              1000
                             20             177.15         153.1          224.45        205.5    185.5                                                                  0
                                                                                                                                                                                5           10             15           20          25          30
                             25             2992.8         2096           3751.2        3126     2712.4                                                                                                     Processes


                             30               6534         4495           8116          6428     6122.5                  Figure 10: Average Turnaround Time of CPU Scheduling Algorithms
                                                                                                                                               (Comparative Analysis)
                                  Table 1: Experimental Results for Average Waiting Time




                                                                                                                229                                                                                  http://sites.google.com/site/ijcsis/
                                                                                                                                                                                                     ISSN 1947-5500
                                                                     (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                               Vol. 8, No. 2, 2010
                         VIII. CONCLUSION
   The paper presents a new CPU scheduling algorithm called
SJRR CPU Scheduling Algorithm. Also presented in this
paper are the simulation interface and its working which
interactively takes input from the user and compares the
process set against different algorithm pairs. The results of the
simulation for different process sets using different scheduling
algorithms has been presented graphically in this piece of
work. The last half of the paper provides analytical result with
each set of graph. From the above graphs and results, it is clear
that SJRR is more efficient than First Come First Served,
Round Robin and Priority although it is less efficient than
Shortest Job First. In future, an enhanced and more efficient
version of this algorithm along with enhanced simulation will
be presented.
                             REFERENCES

[1]   Abraham Silberschatz , Peter Baer Galvin, Greg Gagne, “Operating
      System Concepts”,Sixth Edition.
[2]   Milan Milenkovic, “Operating System Concepts and Design”,
      McGRAW-HILL, Computer Science Series, Second Edition.
[3]   H.M.Deitel, “Operating Systems”, Pearson Education, Second Edition.
[4]   http://en.wikipedia.org/wiki/Scheduling (computing).
[5]   Sukanya Suranauwarat, “A CPU Scheduling Algorithm Simulator”, 37th
      ASEE/IEEE Frontiers in Education Conference.
[6]   Akhtar Hussain, “Optimized Performance of CPU Scheduling”, Master’s
      Thesis, National University of Science and Technology.
[7]   M Gary Nutt, “Operating Systems- A Modern Perspective”, Second
      Edition, Pearson Education, 2000




                                                                            230                           http://sites.google.com/site/ijcsis/
                                                                                                          ISSN 1947-5500