You are on page 1of 5

(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 2 Department of Computer Science Maharishi University of Management Fairfield,Iowa USA {saeedabb, yasiryc }@gmail.com, farooq@ceme.nust.edu.pk
1

AbstractCentral Processing Unit (CPU) plays a significant role in computer system by transferring its control among different processes. As CPU is a central component, hence it must be used efficiently. Operating system performs an essential task that is known as CPU scheduling for efficient utilization of CPU. CPU scheduling has strong effect on resource utilization as well as overall performance of the system. In this paper, a new CPU scheduling algorithm called Combinatory is proposed that combines the functions of some basic scheduling algorithms. The suggested algorithm was evaluated on some CPU scheduling objectives and it was observed that this algorithm gave good performance as compared to the other existing CPU scheduling algorithms. Keywords-component: Operating System, CPU scheduling, First Come First Serve Algorithm, Shortest Job First Algorithm,

reason behind it is that I/O takes long time to complete its operation and CPU has to remain idle [3, 4]. There are three different types of schedulers that are working in the operating system. Each scheduler has its own tasks that differentiate it from the others. These are: A. Long-term Scheduler It is also called high level scheduler, admission scheduler or job scheduler. It works with the job queue or high level queue and decides which process or job to be admitted to the ready queue for execution. Thus, the admission of the processes to the ready queue for execution is controlled by the long-term scheduler [5]. The major objective of this scheduler is to give balanced mix of jobs i.e. CPU bound and I/O bound, to the short-term scheduler [6]. B. Medium-term Scheduler It is also called mid-term scheduler. This scheduler is responsible to remove the processes from main memory and put them in the secondary memory and vice versa. Thus, it decreases degree of multiprogramming. This is usually known as swapping of processes (swapping-in or swapping out) [5].
Mediumterm Scheduler Suspended and Swapped-out Queue Short-term Scheduler Job Job Queue

I.

INTRODUCTION

Operating system performs variety of tasks in which scheduling is one of the basic task. All the resources of computer are scheduled before use; as CPU is one of the major computer resources therefore its scheduling is vital for operating system [1]. When more than one process is ready to take control of CPU, the operating system must decide which process will take control of CPU first. The component of the operating system that is responsible for making this decision is called scheduler and the algorithm used by it is called scheduling algorithm [2]. In computer system, all processes execute by alternating their states between two burst cycles; CPU burst cycle and I/O burst cycle. Generally, a process starts its execution with a CPU burst then performs I/O (I/O burst), again another CPU burst then another I/O burst and this alternation of burst cycle 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 performs a lot of I/O operations [1]. The typical task performed by the scheduler is to give the control of CPU to another process when one process is doing the I/O operations. The

Longterm Schedule

Ready Queue

CPU

Exit

Interactive Programs

Suspended Queue

Figure 1: Schedulers

39

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

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

C. Short-term Scheduler It is also called dispatcher or CPU scheduler. It decides which process from the ready queue takes control of the CPU next for execution [1]. Short-term scheduler makes scheduling decision much more frequently as compared to the other two schedulers. This decision is made on the basis of two disciplines these are non-preemptive and preemptive. In nonpreemptive, the scheduler is unable to take control of the CPU forcefully from the processes. Processes take control of the CPU until the completion of execution. In preemptive, the scheduler is able to take control of the CPU forcefully from the processes when it decides to take CPU to the other process [5]. Design of CPU scheduling algorithm affects the success of CPU scheduler. CPU scheduling algorithms mainly depends on the criteria; CPU utilization, throughput, waiting time, turnaround time and response time [5]. Consequently, the major attempt of this work is to develop an optimal CPU scheduling algorithm that is suited for all types of processes and gives fair execution time to each process. The organization of rest of the paper is as follow: Section II discuses existing scheduling algorithms. Section III describes proposed scheduling algorithm. Section IV contains pseudo code of the algorithm. Experimental Evaluation & Results have been given in Section V followed by conclusion. II. OVERVIEW OF EXISTING CPU SCHEDULING ALGORITHMS

B. Shortest Job First (SJF) Scheduling This algorithm is non-preemptive in nature and permits the processes to execute first that have smaller burst time [10]. If more than one process has same burst time then control of CPU is assigned to them on the basis of First Come First Served. In most system, this algorithm is implemented for maximum throughput [5]. SJF algorithm is an optimal scheduling algorithm; it gives minimum average waiting time and average turnaround time [11] because it executes small processes before large ones. The difficulty of this algorithm is to know length of CPU burst of next process and it is usually unpredictable [9], there is also a problem of starvation in this algorithm because the arrival of processes having short CPU burst prevents processes having long CPU burst to execute [5]. C. Round Robin (RR) Scheduling In this algorithm, a small unit of time called time quantum or time slice is assigned to each process. According to that time quantum processes are executed and if time quantum of any process expires before its complete execution, it is put at the end of the ready queue and control of the CPU is assigned to the next incoming process. Performance of Round Robin totally depends on the size of time quantum. If size of time quantum is too small; it will cause many context switches and also affect the CPU efficiency. If time quantum is too large; it will give poor response time that approximately equal to FCFS [1]. This algorithm is preemptive in nature [7] and is suitable for time sharing systems. Round Robin algorithm gives high waiting time therefore deadlines are rarely met in it [5]. D. Priority Based Scheduling In this algorithm, priority is associated with each process and on the basis of that priority CPU is allocated to the processes. Higher priority processes are executed first and lower priority processes are executed at end [4]. If multiple processes having the same priorities are ready to execute, control of CPU is assigned to these processes on the basis of FCFS [1, 3]. In this algorithm, average waiting time and response time of higher priority processes is small while waiting time increases for processes having equal priority [5, 12]. The major problem with this algorithm is problem of starvation that can be solved by a technique called aging [1]. E. SJRR CPU Scheduling Algorithm In this algorithm, all the incoming processes are sorted in ascending order in the ready queue. Time quantum is

The basic CPU scheduling algorithms, their advantages and disadvantages are discussed in this section. A. First Come First Served (FCFS) Scheduling It is the simplest CPU scheduling algorithm that permits the execution of the process on the basis of their arrival time means the process having earlier arrival time will be executed first. Once the control of CPU is assigned to the process, it will not leave the CPU until it completes its execution. For small processes this technique is fair but for long processes it is quite unfair [7]. This algorithm is simple and can be implemented easily using FIFO queue. The problems of this algorithm are: the average waiting time, average turnaround time and average response time are high therefore it is not suitable for real time applications [9]. A long burst time process can monopolize CPU, even if burst time of other process is too short called convoy effect. Hence throughput is low [8].

Identify applicable sponsor/s here. (sponsors)

40

http://sites.google.com/site/ijcsis/ 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 time quantum, processes are executed one after another. If time quantum expires, CPU is taken from the processes forcefully and assigned to the next process; the preempted processes are put at the end of the ready queue [7]. SJRR is provides fair share to each process and is useful in time sharing systems. It provides minimum average time and average turnaround time [7]. The problem with this algorithm is that if calculated time quantum is too small then there is overhead of more context switches. III. PROPOSED SCHEDULING ALGORITHM

IV.
f 0 temp 0 total_tatime 0.0 tw_time 0.0 avg_wt 0.0 avg_tatime 0.0 For i F[i]

PSEUDO CODE

0 to process atime[i] + btime[i]

In this algorithm, a new factor F is calculated that is addition of two basic factors (arrival time and burst time of the processes). Here is the equation that shows this relation: F= Arrival Time + Burst Time This factor F is assigned to each process and on the basis of this factor processes are arranged in ascending order in the ready queue. Processes having highest value of the factor are executed first and those with lowest value of the factor are executed next. Depend on this new factor CPU executes the process that: Has shortest burst time Submit to the system at start Proposed CPU scheduling algorithm reduces waiting time, turnaround time and response time and also increases CPU utilization and throughput. It has resolved the problem of starvation at much more extent and there is no problem of context switching in this algorithm. The working of the proposed algorithm is as given below: 1. Take list of processes, their burst time and arrival time. 2. Find the factor F by adding arrival time and burst time of processes. 3. On the basis of factor, arrange processes and their relative burst time in ascending order using any sorting technique. 4. Calculate waiting time of each process. 5. Iterate through the list of processes a. Add total waiting time with waiting time of each process to find total waiting time b. Add burst time and waiting time of each process to find turnaround time c. Add total turnaround time and turnaround time of each process to find total turnaround time 6. Average waiting time is calculated by diving total waiting time with total number of processes. 7. Average turnaround time is calculated by dividing total turnaround time with total number of processes.

For i process-1 to 0 For j 1 to process IF F [j-1] > F[j] f F[j-1] F [j-1] F[j] F [j] f temp btime[j-1] btime[j-1] btime[j] btime[j] temp ptemp proname[j-1] proname[j-1] proname [j] proname[j] ptemp wtime [1] 0 For j 1 to count wtime[j] btime [j-1] + wtime [j-1]

For j 0 to process tw_time tw_time + wtime[j] tatime[j] b[j] + wtime[j] total_ tatime total_tatime+ tatime[j] avg_wt tw_time / process avg_tatime total_tatime/ process

V.

EXPERIMENTAL EVALUATION & RESULTS

To explain the performance of proposed scheduling algorithm and to compare its performance with the performance of existing algorithms; consider the following set of processes along with their burst time, arrival time in milliseconds and priority in numbers as shown in the Table 1:

Process Name P1 P2 P3 P4 P5

Arrival Time 0 1 2 3 4

Burst Time 20 10 3 13 10

Priority 6 8 2 1 4

Table 1: Set of Processes

41

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

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

Proposed CPU scheduling algorithm was implemented with existing CPU scheduling algorithms and performed detailed analysis by using Deterministic Evaluation method. Following Gantt charts of each algorithms, average waiting time and average turnaround time was obtained from this method. A. Gantt Chart: a. First Come First Served Scheduling:
P1 P2 P3 P4 P5

waiting time of each process and average waiting time for each scheduling algorithm. C. Turnaround Time: Turnaround Time of the process is calculated as the interval between the time of the submission of the process to the time of the completion of that process. From the Gantt chart of the proposed Combinatory Scheduling, it is observed that turnaround time for the processes P1, P2, P3, P4 & P5 is 20, 2, 29, 5& 10 respectively and the average turnaround time is (20+2+29+5+10) /5=13.2ms. Turnaround Time for all other algorithms is calculated in the same way. Table 3 shows turnaround time of each process and average turnaround time for each scheduling algorithm.

10

12

21

24

29

Figure 2: Gantt chart for FCFS

b.

Shortest Job First Scheduling:


P2 P4 P5 P3 P1

10

19

29

Process Name
FCFS SJF

Waiting Time (ms)


RR Priority SJRR Proposed Algorithm

Figure 3: Gantt chart for SJF

c.

Round Robin Scheduling:

P1 P2 P3

0 10 12 21 24 13.4

19 0 10 2 5 7.2

18 8 20 18 21 17

11 9 0 21 24 13

19 0 15 2 5 8.2

10 0 20 2 5 7.4

Here time quantum assigns to each process is 8.


P1 P2 P3 P4 P5 P1

10

18

21

26

28

29

P3 P4 P5

Figure 4: Gantt chart for RR

d.

Priority Based Scheduling:


P3 P2 P1 P4 P5

11

21

24

29

Avg. Waiting Time

Figure 5: Gantt chart for Priority Scheduling

e.

SJRR Scheduling:
P2 P4 P5 P3 P1 P3 P1

Table 2: Waiting Time of each process and Average Waiting Time for Each Scheduling Algorithm

10

15

20

24

29

Figure 6: Gantt chart for SJRR Scheduling

Process Name
FCFS

Turnaround Time (ms)


SJF RR Priority SJRR Proposed Algorithm

f.

Proposed Combinatory CPU Scheduling:


P2 P4 P5 P1 P3 P1

10 12 21 24 29 19.2

29 2 19 5 10 13

28 10 29 21 26
22.8

21 11 9 24 29 18.8

29 2 24 5 10 14

20 2 29 5 10 13.2

10

20

29

P2 P3 P4 P5
Avg. Turnaround Time

Figure 7: Gantt chart for Proposed Combinatory Scheduling

B. Waiting Time: 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 Gantt chart of the proposed Combinatory Scheduling, it is observed that waiting time for the processes P2, P4, P5, P1 & P3 is 0, 2, 5, 10 & 20 respectively and the average waiting time is (0+2+5+10+20) /5=7.4ms. Waiting Time for all other algorithms is calculated in the same way. Table 2 shows

Table 3: Turnaround Time of each process and Average Turnaround Time for Each Scheduling Algorithm

42

http://sites.google.com/site/ijcsis/ 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 been simulated with C#.NET code and comparisons are made between the performance of proposed algorithm and existing algorithms. Graphical representation of these comparisons is shown in Figure 8 and Figure 9.

VI.

CONCLUSION

From the comparison of the obtained results, it is observed that proposed algorithm has successfully beaten the existing 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. REFERENCES
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 1812-5638 [4] E. O. Oyetunji, A. E. Oluleye, Performance Assessment of Some CPU Scheduling Algorithms, Research Journal of Information Technology 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 1546-9239 [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, 2009. [1]

Figure 8: Comparison of Waiting Time of Proposed Algorithm with Waiting Time of Existing Algorithms

Figure 9: Comparison of Turnaround Time of Proposed 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 algorithm.

43

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

You might also like