Combinatory CPU Scheduling Algorithm by ijcsis


More Info
									                                                            (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                             Vol. 8, No. 7, October 2010

               Combinatory CPU Scheduling Algorithm
                                    Saeeda Bibi 1, Farooque Azam1, ,Yasir Chaudhry 2
                                             Department of Computer Engineering
                                        College of Electrical and Mechanical Engineering,
                               National University of Science and Technology, Islamabad, Pakistan
                                               Department of Computer Science
                                              Maharishi University of Management
                                                       Fairfield,Iowa USA
                                  {saeedabb, yasiryc },

Abstract—Central Processing Unit (CPU) plays a significant role         reason behind it is that I/O takes long time to complete its
in computer system by transferring its control among different          operation and CPU has to remain idle [3, 4].
processes. As CPU is a central component, hence it must be used
efficiently. Operating system performs an essential task that is            There are three different types of schedulers that are
known as CPU scheduling for efficient utilization of CPU. CPU
                                                                        working in the operating system. Each scheduler has its own
scheduling has strong effect on resource utilization as well as
overall performance of the system. In this paper, a new CPU             tasks that differentiate it from the others. These are:
scheduling algorithm called Combinatory is proposed that
combines the functions of some basic scheduling algorithms. The         A. Long-term Scheduler
suggested algorithm was evaluated on some CPU scheduling
                                                                             It is also called high level scheduler, admission scheduler
objectives and it was observed that this algorithm gave good
performance as compared to the other existing CPU scheduling            or job scheduler. It works with the job queue or high level
algorithms.                                                             queue and decides which process or job to be admitted to the
                                                                        ready queue for execution. Thus, the admission of the
    Keywords-component: Operating System, CPU scheduling,
First Come First Serve Algorithm, Shortest Job First Algorithm,         processes to the ready queue for execution is controlled by the
                                                                        long-term scheduler [5]. The major objective of this scheduler
                      I.   INTRODUCTION                                 is to give balanced mix of jobs i.e. CPU bound and I/O bound,
                                                                        to the short-term scheduler [6].
    Operating system performs variety of tasks in which                 B. Medium-term Scheduler
scheduling is one of the basic task. All the resources of
computer are scheduled before use; as CPU is one of the major                It is also called mid-term scheduler. This scheduler is
computer resources therefore its scheduling is vital for                responsible to remove the processes from main memory and
operating system [1]. When more than one process is ready to            put them in the secondary memory and vice versa. Thus, it
take control of CPU, the operating system must decide which             decreases degree of multiprogramming. This is usually known
process will take control of CPU first. The component of the            as swapping of processes (“swapping-in” or “swapping out”)
operating system that is responsible for making this decision is        [5].
called scheduler and the algorithm used by it is called                                      term
scheduling algorithm [2].                                                                                   Suspended and
                                                                                 Long-                       Swapped-out
    In computer system, all processes execute by alternating                      term                          Queue
their states between two burst cycles; CPU burst cycle and I/O                  Schedule
burst cycle. Generally, a process starts its execution with a                                                    Scheduler
CPU burst then performs I/O (I/O burst), again another CPU
burst then another I/O burst and this alternation of burst cycle        Job       Job                    Ready                   CPU          Exit
                                                                                 Queue                   Queue
continues until the completion of the process execution. CPU
bound process is that which performs a lot of computational
tasks and do little I/O while I/O bound process is that which                    Interactive                           Suspended
                                                                                  Programs                               Queue
performs a lot of I/O operations [1]. The typical task performed
by the scheduler is to give the control of CPU to another                                       Figure 1: Schedulers
process when one process is doing the I/O operations. The

                                                                                                       ISSN 1947-5500
                                                               (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                Vol. 8, No. 7, October 2010
C. Short-term Scheduler                                                    B. Shortest Job First (SJF) Scheduling
    It is also called dispatcher or CPU scheduler. It decides                  This algorithm is non-preemptive in nature and permits the
which process from the ready queue takes control of the CPU                processes to execute first that have smaller burst time [10]. If
next for execution [1]. Short-term scheduler makes scheduling              more than one process has same burst time then control of CPU
decision much more frequently as compared to the other two                 is assigned to them on the basis of First Come First Served. In
schedulers. This decision is made on the basis of two                      most system, this algorithm is implemented for maximum
disciplines these are non-preemptive and preemptive. In non-               throughput [5].
preemptive, the scheduler is unable to take control of the CPU                 SJF algorithm is an optimal scheduling algorithm; it gives
forcefully from the processes. Processes take control of the               minimum average waiting time and average turnaround time
CPU until the completion of execution. In preemptive, the                  [11] because it executes small processes before large ones. The
scheduler is able to take control of the CPU forcefully from the           difficulty of this algorithm is to know length of CPU burst of
processes when it decides to take CPU to the other process [5].            next process and it is usually unpredictable [9], there is also a
                                                                           problem of starvation in this algorithm because the arrival of
    Design of CPU scheduling algorithm affects the success of              processes having short CPU burst prevents processes having
CPU scheduler. CPU scheduling algorithms mainly depends                    long CPU burst to execute [5].
on the criteria; CPU utilization, throughput, waiting time,
turnaround time and response time [5]. Consequently, the                   C. Round Robin (RR) Scheduling
major attempt of this work is to develop an optimal CPU                        In this algorithm, a small unit of time called time quantum
scheduling algorithm that is suited for all types of processes             or time slice is assigned to each process. According to that time
and gives fair execution time to each process.                             quantum processes are executed and if time quantum of any
    The organization of rest of the paper is as follow: Section II         process expires before its complete execution, it is put at the
discuses existing scheduling algorithms. Section III describes             end of the ready queue and control of the CPU is assigned to
proposed scheduling algorithm. Section IV contains pseudo                  the next incoming process.
code of the algorithm. Experimental Evaluation & Results have                  Performance of Round Robin totally depends on the size of
been given in Section V followed by conclusion.                            time quantum. If size of time quantum is too small; it will
                                                                           cause many context switches and also affect the CPU
        II.    OVERVIEW OF EXISTING CPU SCHEDULING                         efficiency. If time quantum is too large; it will give poor
                        ALGORITHMS                                         response time that approximately equal to FCFS [1]. This
                                                                           algorithm is preemptive in nature [7] and is suitable for time
   The basic CPU scheduling algorithms, their advantages and               sharing systems. Round Robin algorithm gives high waiting
disadvantages are discussed in this section.                               time therefore deadlines are rarely met in it [5].
A. First Come First Served (FCFS) Scheduling
                                                                           D. Priority Based Scheduling
    It is the simplest CPU scheduling algorithm that permits the
execution of the process on the basis of their arrival time means             In this algorithm, priority is associated with each process
the process having earlier arrival time will be executed first.            and on the basis of that priority CPU is allocated to the
Once the control of CPU is assigned to the process, it will not            processes. Higher priority processes are executed first and
leave the CPU until it completes its execution. For small                  lower priority processes are executed at end [4]. If multiple
processes this technique is fair but for long processes it is quite        processes having the same priorities are ready to execute,
unfair [7].                                                                control of CPU is assigned to these processes on the basis of
                                                                           FCFS [1, 3].
    This algorithm is simple and can be implemented easily
using FIFO queue. The problems of this algorithm are: the                      In this algorithm, average waiting time and response time
average waiting time, average turnaround time and average                  of higher priority processes is small while waiting time
response time are high therefore it is not suitable for real time          increases for processes having equal priority [5, 12]. The major
applications [9]. A long burst time process can monopolize                 problem with this algorithm is problem of starvation that can be
CPU, even if burst time of other process is too short called               solved by a technique called aging [1].
convoy effect. Hence throughput is low [8].
                                                                           E. SJRR CPU Scheduling Algorithm
                                                                              In this algorithm, all the incoming processes are sorted in
                                                                           ascending order in the ready queue. Time quantum is
   Identify applicable sponsor/s here. (sponsors)

                                                                                                      ISSN 1947-5500
                                                             (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                              Vol. 8, No. 7, October 2010
calculated and assigned to each process. On the basis of that                                    IV.    PSEUDO CODE
time quantum, processes are executed one after another. If                       f 0
time quantum expires, CPU is taken from the processes                            temp 0
forcefully and assigned to the next process; the preempted                       total_tatime 0.0
                                                                                 tw_time 0.0
processes are put at the end of the ready queue [7].                             avg_wt 0.0
   SJRR is provides fair share to each process and is useful in                  avg_tatime 0.0
time sharing systems. It provides minimum average time and
                                                                                 For i      0 to process
average turnaround time [7]. The problem with this algorithm                      F[i]       atime[i] + btime[i]
is that if calculated time quantum is too small then there is
overhead of more context switches.                                              For i process-1 to 0
                                                                                For j 1 to process
          III.   PROPOSED SCHEDULING ALGORITHM                                       IF F [j-1] > F[j]
                                                                                            f F[j-1]
    In this algorithm, a new factor F is calculated that is                                 F [j-1] F[j]
addition of two basic factors (arrival time and burst time of the                           F [j] f
processes). Here is the equation that shows this relation:                                 temp btime[j-1]
                                                                                            btime[j-1] btime[j]
                   F= Arrival Time + Burst Time
                                                                                            btime[j] temp
     This factor F is assigned to each process and on the basis                             ptemp proname[j-1]
of this factor processes are arranged in ascending order in the                             proname[j-1] proname [j]
ready queue. Processes having highest value of the factor are                              proname[j] ptemp
executed first and those with lowest value of the factor are                   wtime [1] 0
executed next. Depend on this new factor CPU executes the                      For j 1 to count
process that:                                                                       wtime[j]  btime [j-1] + wtime [j-1]
     • Has shortest burst time
     • Submit to the system at start                                           For j 0 to process
    Proposed CPU scheduling algorithm reduces waiting time,                       tw_time tw_time + wtime[j]
turnaround time and response time and also increases CPU                          tatime[j] b[j] + wtime[j]
                                                                                  total_ tatime total_tatime+ tatime[j]
utilization and throughput. It has resolved the problem of
starvation at much more extent and there is no problem of                      avg_wt tw_time / process
context switching in this algorithm.                                           avg_tatime total_tatime/ process

  The working of the proposed algorithm is as given below:                       V.      EXPERIMENTAL EVALUATION & RESULTS
   1. Take list of processes, their burst time and arrival                   To explain the performance of proposed scheduling
       time.                                                             algorithm and to compare its performance with the
   2. Find the factor F by adding arrival time and burst                 performance of existing algorithms; consider the following set
       time of processes.                                                of processes along with their burst time, arrival time in
   3. On the basis of factor, arrange processes and their                milliseconds and priority in numbers as shown in the Table 1:
       relative burst time in ascending order using any
       sorting technique.
                                                                                  Process         Arrival          Burst        Priority 
   4. Calculate waiting time of each process.
                                                                                   Name            Time            Time 
   5. Iterate through the list of processes
         a. Add total waiting time with waiting time of                               P1               0             20              6 
               each process to find total waiting time
         b. Add burst time and waiting time of each
                                                                                      P2               1             10              8 
               process to find turnaround time                                        P3               2              3              2 
         c. Add total turnaround time and turnaround time
               of each process to find total turnaround time                          P4               3             13              1 
   6. Average waiting time is calculated by diving total                              P5               4             10              4 
       waiting time with total number of processes.
                                                                                               Table 1: Set of Processes
   7. Average turnaround time is calculated by dividing
       total turnaround time with total number of processes.

                                                                                                       ISSN 1947-5500
                                                                                     (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                                                      Vol. 8, No. 7, October 2010
    Proposed CPU scheduling algorithm was implemented                                         waiting time of each process and average waiting time for each
with existing CPU scheduling algorithms and performed                                         scheduling algorithm.
detailed analysis by using Deterministic Evaluation method.
                                                                                              C. Turnaround Time:
Following Gantt charts of each algorithms, average waiting
time and average turnaround time was obtained from this                                           Turnaround Time of the process is calculated as the interval
method.                                                                                       between the time of the submission of the process to the time of
A. Gantt Chart:                                                                               the completion of that process. From the Gantt chart of the
                                                                                              proposed Combinatory Scheduling, it is observed that
       a.    First Come First Served Scheduling:
                                                                                              turnaround time for the processes P1, P2, P3, P4 & P5 is 20, 2,
            P1                 P2             P3          P4                  P5              29, 5& 10 respectively and the average turnaround time is
   0                 10              12             21             24               29        (20+2+29+5+10) /5=13.2ms. Turnaround Time for all other
                                                                                              algorithms is calculated in the same way. Table 3 shows
                          Figure 2: Gantt chart for FCFS
                                                                                              turnaround time of each process and average turnaround time
       b.    Shortest Job First Scheduling:                                                   for each scheduling algorithm.
            P2                 P4             P5          P3                  P1              Process                       Waiting Time (ms)
   0                 2               5              10             19               29        Name
                                                                                                             FCFS    SJF     RR      Priority     SJRR      Proposed
                              Figure 3: Gantt chart for SJF
       c.    Round Robin Scheduling:                                                          P1               0      19      18        11          19         10
   Here time quantum assigns to each process is 8.
                                                                                              P2               10      0       8         9          0              0
            P1           P2         P3         P4        P5         P1         P3
                                                                                              P3               12     10      20         0         15          20
   0             8            10         18         21        26         28         29
                              Figure 4: Gantt chart for RR                                    P4               21      2      18        21          2              2
       d.    Priority Based Scheduling:                                                       P5               24      5      21        24          5              5
            P3                 P2             P1          P4                  P5              Avg.            13.4    7.2     17        13         8.2         7.4
   0                 9              11              21             24               29
                 Figure 5: Gantt chart for Priority Scheduling
                                                                                                   Table 2: Waiting Time of each process and Average Waiting
       e.    SJRR Scheduling:                                                                                Time for Each Scheduling Algorithm

            P2           P4         P5         P3        P1         P3         P1
   0             2             5         10         15        20         24         29        Process                   Turnaround Time (ms)
                  Figure 6: Gantt chart for SJRR Scheduling                                                  FCFS    SJF     RR      Priority     SJRR     Proposed

       f.    Proposed Combinatory CPU Scheduling:
            P2                 P4             P5          P1                  P3              P1              10      29      28        21         29          20
   0                 2              5               10             20               29        P2              12      2       10        11          2              2
  Figure 7: Gantt chart for Proposed Combinatory Scheduling
                                                                                              P3              21      19      29         9         24          29
B. Waiting Time:
                                                                                              P4              24      5       21        24          5              5
   Waiting Time of the process is calculated as the time taken
by the process to wait for the CPU in the ready queue. From the                               P5              29      10      26        29         10          10
Gantt chart of the proposed Combinatory Scheduling, it is                                     Avg.                           22.8
                                                                                                             19.2     13               18.8        14         13.2
observed that waiting time for the processes P2, P4, P5, P1 &                                 Turnaround
P3 is 0, 2, 5, 10 & 20 respectively and the average waiting time                              Time
is (0+2+5+10+20) /5=7.4ms. Waiting Time for all other                                                 Table 3: Turnaround Time of each process and Average
algorithms is calculated in the same way. Table 2 shows                                                Turnaround Time for Each Scheduling Algorithm

                                                                                                                            ISSN 1947-5500
                                                           (IJCSIS) International Journal of Computer Science and Information Security,
                                                                                                            Vol. 8, No. 7, October 2010
   The proposed algorithm along with existing algorithms has                                  VI.     CONCLUSION
been simulated with C#.NET code and comparisons are made
between the performance of proposed algorithm and existing              From the comparison of the obtained results, it is observed
algorithms. Graphical representation of these comparisons is         that proposed algorithm has successfully beaten the existing
shown in Figure 8 and Figure 9.                                      CPU scheduling algorithms. It provides good performance in
                                                                     the scheduling policy. As SJF is optimal scheduling algorithm
                                                                     but for large processes, it gives increased waiting time and
                                                                     sometimes long processes will never execute and remain
                                                                     starved. This problem can be overcome by the proposed
                                                                     algorithm. In future, the working of proposed algorithm will
                                                                     be tested on any open source operating system.


                                                                     [1]  Abraham Silberschatz , Peter Baer Galvin, Greg Gagne, “Operating
                                                                          System Concepts”,Sixth Edition.
                                                                     [2] Andrew S. Tanenbaum, Albert S. Woodhull, “Operating Systems Design
                                                                          and Implementation”, Second Edition
                                                                     [3] Mohammed A. F. Husainy, “Best-Job-First CPU Scheduling
                                                                          Algorithm”, Information Technology Journal 6(2): 288-293, 2007, ISSN
                                                                     [4] E. O. Oyetunji, A. E. Oluleye, “Performance Assessment of Some CPU
 Figure 8: Comparison of Waiting Time of Proposed Algorithm               Scheduling Algorithms”, Research Journal of Information Technology
           with Waiting Time of Existing Algorithms                       1(1): 22-26, 2009, ISSN: 2041-3114
                                                                     [5] Sindhu M., Rajkamal R., Vigneshwaran P., "An Optimum Multilevel
                                                                          CPU Scheduling Algorithm," ACE, pp.90-94, 2010 IEEE International
                                                                          Conference on Advances in Computer Engineering, 2010
                                                                     [6] Milan Milenkovic, “Operating System Concepts and Design”,
                                                                          McGRAW-HILL, Computer Science Series, Second Edition.
                                                                     [7] Saeeda Bibi, Farooque Azam, Sameera Amjad, Wasi Haider Butt, Hina
                                                                          Gull, Rashid Ahmed, Yasir Chaudhry “An Efficient SJRR CPU
                                                                          Scheduling Algorithm” International Journal of Computer Science and
                                                                          Information Security, Vol. 8, No. 2,2010
                                                                     [8] Maj. Umar Saleem Butt and Dr. Muhammad Younus Javed, “Simulation
                                                                          of CPU Scheduling Algorithms”,0-7803-6355-8/00/$10.00@2000 IEEE.
                                                                     [9] Rami J. Matarneh, “Self Adjustment Time Quantum in Round Robin
                                                                          Algorithm Depending on Burst Time of the Now Running Processes”,
                                                                          American Journal of Applied Sciences 6(10): 18311-1837, 2009, ISSN
                                                                     [10] Gary Nutt, “Operating Systems, A Modern Perspective”, Second Edition
                                                                     [11] Andrew S.Tanenbaum, Albert S. Woodhull “A Modern Operating
                                                                          System”, Second Edition
                                                                     [12] Md. Mamunur Rashid and Md. Nasim Adhtar, “A New Multilevel CPU
                                                                          Scheduling Algorithm”, Journals of Applied Sciences 6(9): 2036-2039,
   Figure 9: Comparison of Turnaround Time of Proposed                    2009.
   Algorithm with Turnaround Time of Existing Algorithms

   From the Gantt charts of proposed algorithm and existing
algorithms (Figure 2 to 7), it is noticed that waiting time,
turnaround time and response time of the proposed algorithms
are smaller than existing algorithms. The above two graphs in
Figure 8 and 9 also represents that proposed scheduling
algorithm is optimum as compared to other existing
scheduling algorithms. Maximum CPU utilization and
throughput can also be obtained from proposed scheduling

                                                                                                    ISSN 1947-5500

To top