• No results found

Studies on the Comparative Analysis and Performance Prediction of Various Scheduling Algorithms

N/A
N/A
Protected

Academic year: 2022

Share "Studies on the Comparative Analysis and Performance Prediction of Various Scheduling Algorithms"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Sourabh Shastri, IJRIT-81 International Journal of Research in Information Technology

(IJRIT)

www.ijrit.com ISSN 2001-5569

Studies on the Comparative Analysis and Performance Prediction of Various Scheduling Algorithms

1Sourabh Shastri* 2Anand Sharma 3Vibhakar Mansotra

1Department of Computer Science & IT, Bhaderwah Campus, University of Jammu, J&K, India

2,3Department of Computer Science & IT, University of Jammu, J&K, India

Abstract:

Scheduling is a policy of operating system used for controlling the order of the process which is to be executed by the CPU. The goal of scheduling is to increase CPU utilization and to finish the entire task in least possible time. The present piece of investigation documents the comparative analysis of four different CPU scheduling algorithms viz. First Come First Serve, Shortest Job First, Round Robin and Priority Scheduling by comparing their average waiting time in different runs. The implementation is carried out in C# using Microsoft Visual Studio 2010 by creating a graphical user interface.

I Introduction:

In a multiprogramming environment, multiple processes can be loaded into the main memory for their execution. In main memory, these processes reside in ready queue. As a process executes, it changes its state. The state of the process is the current activity of that process. The states where a process can stay are new, ready, running, waiting and terminated [1]. The process may be in any of the mentioned states. In the running state, only one process is present because this is the state where actually the CPU executes the process. Many processes may be in ready and waiting states.

The Operating System helps in determining which process is allocated to CPU with the help of CPU schedulers [2]. CPU schedulers are Operating System modules which select the next process to be admitted into the system and the next process to run. There are three types of schedulers: Long term scheduler, Short term scheduler and Medium term scheduler.

Long term scheduler is also called as job scheduler that selects processes from disk and loads the processes into memory for execution. Short term scheduler is also called as CPU scheduler that selects processes from memory and allocates the CPU to one of them. Medium term scheduler swaps out those processes which takes more memory or having low priority to free up main memory for other processes. The swapped out processes can be called back when more memory is available.

(2)

Sourabh Shastri, IJRIT-82 The algorithms concerns with CPU schedulers are known as CPU scheduling algorithms. The main purpose of CPU scheduling algorithms is to make use of the resources effectively and efficiently. Different CPU scheduling algorithms have different properties and many criteria have been suggested for comparing CPU scheduling algorithms. The criteria includes: CPU utilization, throughput, turnaround time, waiting time, response time, fairness etc. [3]. CPU utilization means to keep the CPU busy all times. Throughput means maximum number of jobs processed per unit time. Turnaround time is the total time from submission to completion. Waiting time is equal to Turnaround time – CPU time. Response time is the amount of time from submission till the first response. Fairness means each process gets a fair share of the CPU.

CPU scheduling algorithms can be divided into two categories: Non preemptive and preemptive. In non preemptive CPU scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state. Examples of non preemptive CPU scheduling algorithms are First Come First Serve and Shortest Job First. In preemptive scheduling, process may be preemptive before the completion of the burst time based on some time slice or priority.

Examples of preemptive scheduling are Round Robin, Priority Scheduling etc [4].

II CPU Scheduling Algorithms:

CPU scheduling algorithms deal with the complexity of choosing which of the processes in the ready queue is to be allocated the CPU. The fundamental CPU scheduling algorithms are First Come First Serve, Shortest Job First, Round Robin and Priority Scheduling [5]. These algorithms are described here:

First Come First Serve (FCFS):

The functioning of this algorithm is maintained by First in First out (FIFO) queue.

With this scheme, the process that requests the CPU first is allocated the CPU first [6].

Scheduling overhead is minimal because context switching only occurs after the termination of a process. Turnaround time, waiting time and response time are high in this algorithm [7].

Throughput is low in this algorithm because once the CPU has been allocated to the process that process continues with the CPU until it releases the CPU. First Come First Serve algorithm is non preemptive because a long process may block all other processes and releases the CPU either by terminating or some I/O request. Let us consider an example of 05 processes.

Process ID CPU Time(ms) Arrival Time

A 4 0

B 7 1

C 5 4

D 3 6

E 2 8

(3)

Sourabh Shastri, IJRIT-83 In FCFS, the processes are executed in the order they are received. The various processes are depicted in the following Gantt chart.

A B C D E

0 4 11 16 19 21 Waiting Time for process A is 0 ms, waiting time for process B is 4 - 1 = 3 ms, waiting time for process C is 11 - 4 = 7 ms, waiting time for process D is 16 - 6 = 10 ms, waiting time for process E is 19 - 8 = 11 ms and Average Waiting time is 6.2 ms.

Figure 1:- Graph representing the performance of the Process between CPU time and Waiting time for FCFS.

The average waiting time for FCFS is very poor because a process with 2 ms as CPU time has waiting time of 11 ms.

Shortest Job First (SJF):

In this approach, the scheduling of the process is completed on the basis of shortest execution time. If any two processes have the same CPU time then the FCFS algorithm is used. The SJF algorithm is optimal because it gives the minimum average waiting time for a given set of processes [6]. This algorithm achieved maximum throughput in most of the cases. Let us consider the same example solved for FCFS in SJF. The various processes are depicted in the following Gantt chart.

A C E D B

0 4 9 11 14 21 Waiting Time for process A is 0 ms, waiting time for process B is 14 - 1= 13 ms, waiting time for process C is 4 - 4 = 0 ms, waiting time for process D is 11 - 6 = 5 ms, waiting time for process E is 9 - 8 = 1 ms and Average Waiting time is 3.8 ms.

(4)

Sourabh Shastri, IJRIT-84 Figure 2:- Graph representing the performance of the Process between CPU time and Waiting time for SJF.

The average waiting time for SJF is optimal because this algorithm executes firstly those processes that have shortest execution time.

Round Robin (RR):

Round Robin scheduling algorithm is mainly effective in a time-sharing system or transaction processing system [8]. The prime necessity is to provide reasonably response times and to share the system fairly among all system users. In round robin scheduling, processes are dispatched in FIFO but are given a small amount of CPU time. The small amount of time is called time slice or time quantum. If a process does not complete in a given time slice then it has to wait for its turn and the CPU is given to the next process waiting in the ready queue. If a process completes before the time slice ends the process itself releases the CPU. Round Robin scheduling is always preemptive because no process is owed the CPU for more than one time slice in a row. If the size of the time slice is too large, then this algorithm behaves like FCFS and may cause poor response time. If the time slice is too short then the number of context switches increases that lower the CPU performance. Let us consider again the same example solved for FCFS and SJF in RR with time slice 5 ms. The various processes are depicted in the following Gantt chart.

A B C D E B

0 4 9 14 17 19 21 Waiting Time for process A is 0 ms, waiting time for process B is (4 - 1) + (19 - 9) = 13 ms, waiting time for process C is 9 - 4 = 5 ms, waiting time for process D is 14 - 6 = 8 ms, waiting time for process E is 17 - 8 = 9 ms and Average Waiting time is 7 ms.

(5)

Sourabh Shastri, IJRIT-85 Figure 3:- Graph representing the performance of the Process between CPU time and Waiting time for RR.

The drawback of this algorithm is that it slows down the little processes because they have to share the CPU time with other processes instead of just finishing up quickly [4].

Priority Scheduling (PS):

In Priority scheduling, a priority is associated with each process and the scheduler always selects the highest priority process for execution from the ready queue. If the two processes have the same priority then they are scheduled FCFS. To prevent high priority processes from running indefinitely, the scheduler may decrease the priority of the currently running process at each clock interrupt [9]. Starvation may occur when higher priority processes interrupts the lower priority processes. There is a solution for these lower priority processes called aging i.e. to gradually increase the priority of lower priority processes.

Higher priority processes have smaller waiting time and response time. The main advantage of Priority scheduling is that the important processes can be finished first. Let us consider again the same example solved previously with priorities as: A - 3, B - 1, C - 3, D - 4, E - 2.

The various processes are depicted in the following Gantt chart.

A B E A C D

0 1 8 10 13 18 21 Waiting Time for process A is 0 + (10 - 1) = 9 ms, waiting time for process B is (1 - 1) = 0 ms, waiting time for process C is (13 - 4) = 9 ms, waiting time for process D is 18 - 6 = 12 ms, waiting time for process E is 8 - 8 = 0 ms and Average Waiting time is 6 ms.

(6)

Sourabh Shastri, IJRIT-86 Figure 4:- Graph representing the performance of the Process between CPU time and Waiting time for PR.

In Priority scheduling, overhead is not minimal, nor is it significant [7].

III Implementation using C# in Visual Studio 2010:

The implementation is carried out with C# in Visual Studio 2010 to create the graphical user interface. The CPU time and arrival time are generated by the random number generator for First Come First Serve, Shortest Job First, Round Robin and Priority scheduling algorithms. For the priority scheduling, an additional field is used for entering the priority of all the processes which is also generated through random number generator. It is assumed that the CPU time of process will be generated between 1 and 20. Number of processes will be 5. Arrival time will be generated between 1 and 10. Priority will also generate between 1 and 10. Then the waiting time is calculated for all the processes of four scheduling algorithms. The user can calculate the average waiting time for comparing the algorithms viz.

First Come First Serve, Shortest Job First, Round Robin and Priority scheduling.

(7)

Sourabh Shastri, IJRIT-87 Figure 5: Snapshot of implementation of CPU scheduling algorithms using C# in Visual Studio 2010.

IV Comparison of different scheduling algorithms:

Table -1 compares the average waiting time of four CPU scheduling algorithms for the first five runs and their average.

S.No. FCFS SJF RR PS

1 6.2 3.8 7 6

2 18.4 12.6 25.4 18

3 19 12.2 18 12.8

4 3.8 3.4 4.6 3.8

5 17.2 9.2 14.4 14.8

Average 12.92 8.24 13.88 11.08

Table 1: Average waiting time of first five runs and their average.

Shortest Job First algorithm produces the minimum average waiting time 3.8 in the first run, in the second run it is 12.6 and so on. From the table, it is very much clear that the Shortest Job First CPU scheduling algorithm has minimum value in all cases as compared to the three other algorithms. A graphical representation is shown in the figure 6 with the help of data evaluated in table 1.

Figure 6: Comparison between scheduling algorithms in graphical representation.

The figure 6 gives comparative details of the four CPU scheduling algorithms. The X axis is used to represent the number of runs and the Y axis is used for calculating average waiting time of each algorithm in milliseconds. The last run is actually the average of all previous runs. From the various runs, it is concluded that Shortest Job First has the minimum

0 5 10 15 20 25 30

1 2 3 4 5 6

FCFS SJF RR PS

(8)

Sourabh Shastri, IJRIT-88 average waiting time than all other three algorithms. Thus Shortest Job First algorithm is a good criterion for selecting the process from the ready queue by the CPU scheduler.

V Results and Discussions:

We have calculated the average waiting time after entering the various runs for the processes of different algorithms because waiting time is the criteria for analyzing the CPU algorithms [2]. After comparing various algorithms waiting time, we have found that the Shortest Job First CPU scheduling algorithm has the least average waiting time and it is the best algorithm among the others discussed above in context to waiting time.

VI Conclusion:

The present paper analysis the four CPU scheduling algorithms viz. First Come First Serve, Shortest Job First, Round Robin and Priority scheduling. The implementation was carried out using C# in Microsoft Visual Studio 2010. It was observed that the Shortest Job First CPU scheduling algorithm is least most of the times and hence it was the optimal CPU scheduling algorithms among these four algorithms in context with average waiting time.

VII Future Work:

In the future, we will use some other parameters to compare the different CPU scheduling algorithms.

References:

[1] Ashok Kumar, Dr. Harish Rohil and Suraj Arya, “Analysis of CPU Scheduling Policies through Simulation,” International Journal of Advanced Research in Computer Science and Software Engineering, vol. 3, issue 5, pp. 1158-1162, May 2013.

[2] Vikram Singh and Tirlok Gabba, “Comparative Study of Processes Scheduling Algorithms using Simulator,” International Journal of Computing and Business Research, vol. 4, issue 2, May 2013.

[3] Neetu Goel and Dr. R.B. Garg, “A Comparative Study of CPU Scheduling Algorithms,” International Journal of Graphics & Image Processing, vol. 2, issue 4, pp. 245-251, Nov. 2012.

[4] Lalit Kishor and Dinesh Goyal, “Comparative Analysis of Various Scheduling Algorithms,” International Journal of Advanced Research in Computer Engineering

& Technology, vol. 2, issue 4, pp. 1488-1491, April 2013.

[5] Maria Abur, Aminu Mohammed, Sani Danjuma and Saleh Abdullahi, “A Critical Simulation of CPU Scheduling Algorithm using Exponential Distribution,” International Journal of Computer Science Issues, vol. 8, issue 6, pp. 201-206, Nov. 2011.

[6] Abraham Silberschatz, Peter B. Galvin and Greg Gagne, Operating System Concepts, Eight ed., UK: Wiley, 2010.

(9)

Sourabh Shastri, IJRIT-89 [7] Pushpraj Singh, Vinod Singh and Anjani Pandey, “Analysis and Comparison of CPU Scheduling Algorithms,” International Journal of Emerging Technology and Advanced Engineering, vol. 4, issue 1, pp. 91-95, Jan. 2014.

[8] William Stallings, Operating Systems: Internals and Design Principles, 6th ed., India:

Pearson, 2009.

[9] Andrew S. Tanenbaum, Modern Operating Systems, 2nd ed., USA: Prentice-Hall, Inc., 2001.

References

Related documents

Ethanol and sugar output, domestic demand and export in 2006 Ethanol and sugar output, domestic demand and export in 2020 Sugarcane production and crop area in 2006 and 2020

In order to understand the role of statistical self-similar topol- ogy observed in real river networks on spatial scaling statis- tics of hydrographs, we created Monte Carlo

The TCAM-based deep packet inspection algorithm developed in this paper uses a jumping window scheme, which is supported by position-aware sub-patterns and the state transition

Risikofaktoren für eine erhöhte Mortalität im ersten Jahr nach

With a focus on Europe and taking a health system and governance approach, six major ob- jectives have been identified as follows: (1) to develop frameworks that align

In total, during the time frame of 2014 to 2017 (hospital study data collection period), 600 hospitalization episodes related to the primary (ICDs M31.1 or D59.3 coded as

She does not provide the extensive introduc- tion to the techniques of canning found in the other guides in this section, nor does she provide the traditional recipes found in

Conclusão: A versão em Português europeu do the Alcohol, Smoking and Substance Involvement Screening Test (‘Tabaco’, ‘Bebidas Alcoólicas’ e ‘ Cannabis ’)