Sei sulla pagina 1di 4

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 2, March April 2013 ISSN 2278-6856

Performance Improvement Using CPU Scheduling Algorithm-SRT


1

Neeraj Kumar, 2Nirvikar


1

Assistant Professor (CSE) Institute of Technology Roorkee, Roorkee (ITR) Assistant Professor (MCA) IEC College of Engineering, Greater Noida
2

Abstract: This paper explains a new approach for C P U scheduling algorithms which can be used to improve the performance of CPU in real time operating system. The new approach of CPU Scheduling algorithm is based on the integration of round-robin, SJF scheduling algorithm. Priority is calculated on the basis SJF and time quantum. It retains the advantage of simple round robin in reducing starvation and also integrates the advantage of priority scheduling. The proposed algorithm also implements the concept of SJF and time quantum by assigning new priorities to the processes. Existing round robin CPU scheduling algorithm cannot be implemented in real time operating system due to their large waiting time, large response time, large turnaround time and less throughput. In new approach 2. algorithm improves all the drawbacks of round robin CP U scheduling algorithm. The paper also presents the comparative analysis of proposed algorithm with existing round robin scheduling algorithm on the basis of SJF and time quantum, average waiting time, average turnaround time. Keyword: CPU scheduling, RR and SJF schedule Algorithms, Turnaround time, Waiting Time, Response Time, Burst Time.

the CPU. The time slice value also needs to be small enough to prevent RR from becoming a non-preemptive FCFS algorithm. A good rule of thumb is that the value should be of adequate length to ensure that 80% of all jobs can be completed in one time slice.

1. INTRODUCTION
The round-robin (RR) CPU scheduling algorithm has advantages and disadvantages. An advantage of RR is that starvation is never a problem. RR ensures that all processes in the job (process) queue share a time slice on the processor. Time slicing is defined as the allocation of limited intervals of time (quanta) to programs in contention for use of the CPU. A time slice is simply an amount of time that each job (process) will spend on the processor per iteration of the RR algorithm. All jobs are done in a FCFS algorithm fashion but are preempted after a time slice. The job will either finish in the time slice given or the job will be returned to the tail of the job queue and return to the processor at a later time. This is a disadvantage since all jobs are basically given the same priority. RR also favors short virtual processes and penalizes long ones. Another problem of RR is that the time slice value must be correct. If the time slice value is too small the context switching time is large in relation to actual work done on Volume 2, Issue 2 March April 2013

Figure 1. But the proposed implementation along with the basic RR structure helped with the solution. Scheduling Objectives: A system designer must consider a variety of factors in designing a scheduling algorithm, such as type of systems used and what are user's needs. Depending on the system, the user and designer might expect the scheduler to Maximize throughput: A scheduling algorithm should be capable of servicing the maximum number of processes per unit of time. Avoid indefinite blocking or starvation: A process should not wait for unbounded time before or while process service. Minimize overhead: Overhead causes wastage of resources. But when we use system resources effectively, then overall system performance improves greatly. Enforcement of priorities: if system assigns priorities to processes, the scheduling mechanism should favor the higher-priority processes. Achieve balance between response and utilization: The scheduling mechanism should keep resources of system busy. Favor processes exhibits desirable behavior. Degrade gracefully under heavy load. A system can accomplish these goals in several ways. The scheduler can prevent indefinite blocking of processes through the concept of aging. The scheduler can increase throughput by favoring processes whose requests can be satisfied quickly, or whose completion cause other processes to run.

2. SCHEDULING PARAMETERS
Page 110

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)


Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 2, March April 2013 ISSN 2278-6856
There are different parameters which are measured in CPU Scheduling and on behalf of these parameters one can say which algorithm is better as compare to other, these parameters are as given here. CPU Utilization: It is the average fraction of time, during which the processor is busy. Throughput: It refers to the amount of work completed in a unit of time. The number of processes the system can execute in a period of time. The higher the number, the more work is done by the system. Waiting Time: The average period of time a process spends waiting. Waiting time may be expressed as turnaround time less the actual execution time. Turnaround time: The interval from the time of submission of a process to the time of completion is the turnaround time. Response time: Response time is the time from submission of a request until the first response is produced. Round Robin (RR): The RR algorithm is designed especially for time-sharing systems and is similar to the FCFS algorithm. Here, a small unit of time (called time quantum or time slice) is defined. A time quantum is generally from 10-100 milliseconds. So, the RR algorithm will allow the first process in the queue to run until it expires its quantum (i.e. runs for as long as the time quantum), then run the next process in the queue for the duration of the same time quantum. The RR keeps the ready processes as a FIFO queue. So, new processes are added to the tail of the queue. Depending on the time quantum and the CPU burst requirement of each process, a process may need less than or more than a time quantum to execute on the CPU. In a situation where the process need more than a time quantum, the process runs for the full length of the time quantum and then it is preempted. The preempted process is then added to the tail of the queue again but with its CPU burst now a time quantum less than its previous CPU burst. This continues until the execution of the process is completed. The RR algorithm is naturally preemptive.

3. EXISTING ALGORITHMS

CPU

SCHEDULING

4. Proposed Algorithm (SRT)


1. We select the process which has shortest job and assign this process to CPU for one time quantum (TQ). 2. After completion of one time quantum, compare the time quantum with the remaining CPU burst time(RBT) if remaining CPU burst time(RBT) is less than or equal to time quantum assigns the same process again. 3. Repeat step1 and step2 until all the processes have finished their execution.

There are many CPU Scheduling algorithms but some of them which are commonly used are explained below. First-Come, First-Served (FCFS): This algorithm allocates the CPU to the process that requests the CPU first. This algorithm is easily managed with a FIFO queue. New process enters the queue through the tail of the queue and leaves through the head of the queue (when the process is allocated to the CPU) (1). The processes are allocated to the CPU on the basis of their arrival at the queue. Once a process is allocated to the CPU, it is removed from the queue. A process does not give up CPU until it either terminates or performs IO. Shortest-Job-First (SJF): The SJF algorithm associates the length of the next CPU burst w ith each processes such that that the process that have the smallest next CPU burst is allocated to the CPU. The SJF uses the FCFS to break tie (a situation where two processes have the same length next CPU burst). The SJF algorithm may be implemented as either a preemptive or non-preemptive algorithms. When the execution of a process that is currently running is interrupted in order to give the CPU to a new process with a shorter next CPU burst, it is called a preemptive SJF. On the other hand, the nonpreemptive SJF will allow the currently running process to finish its CPU burst before a new process is allocated to the CPU. Priority Scheduling (PS): The PS algorithm associates with each process a priority and the CPU is allocated to the process based on their priorities. Usually, lower numbers are used to represent higher priorities. The process with the highest priority is allocated first. If there are multiple processes with same priority, typically the FCFS is used to break tie.

Volume 2, Issue 2 March April 2013

Page 111

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)


Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 2, March April 2013 ISSN 2278-6856 4. SRT ILLUSTRATION BY TAKING EXAMPLE
We have four processes P1, P2, P3 and P4 in ready queue arriving at time 0 with burst time 15, 7, 28 and 19 respectively. We consider Time quantum (TQ) is assumed 10 milliseconds (ms). In step1, we select the process which has shortest job process. The process P2 has shortest CPU burst time and assign P2 to CPU, after execution of allocated process for time interval to 7 ms, P2 has finished execution, it will be removed from the ready queue. Next process in the ready queue which has shortest job is P1 with 15 ms CPU burst time. CPU will be allocated to P1 for a time interval of 10 ms. P1 has remaining CPU burst time to 5 ms. It will be compared to time quantum so it is less than the specified TQ value so P1 is allocated again to CPU for remaining time interval to 5 ms. P1 has finished execution and it will be removed from the ready queue. Next process in the ready queue which has shortest job is P4 with 19 ms CPU burst time. CPU will be allocated to P4 for a time interval of 10 ms. since the remaining CPU burst time of P3 is less than the TQ, CPU will be allocated again to P4 for a time interval of 9 ms. Now process P4 has finished execution, it will be removed from the ready queue. Next process in the ready queue which has shortest job is P3 with 28 ms CPU burst time. CPU will be allocated to P4 for a time interval of 10 ms. since the remaining CPU burst time of P3 is more than the TQ, but no more process is in ready queue CPU will be allocated again to P4 for the remaining time interval 18 ms. Again Now process P3 has finished execution, it will be removed from the ready queue. The waiting time is 0 ms for P2, 7 ms for P1, 22 ms for P4 and 42 ms for P3, The average waiting time is 17.78 ms. Using the same set of process with same arrival and CPU burst times, the average waiting time is 30.25 ms in RR. 4.1. EXPERIMENTAL RESULT The environment in which the execution takes place is a single processor environment and all the processes are independent. All the processes have equal priority. All the attributes like burst time, number of processes and the time slice of all the processes are known before submitting the processes to the processor. The time quantum is taken in milliseconds. For experimental observation it is considered that the arrival time of all processes is zero. Case Studies: Example IST Suppose RR time quantum =10 Table 1. Processes P1 P2 P3 P4 P5 Burst time in (ms) 20 34 5 12 26 According to simple Round-Robin Algorithm: GANTT chart

P1 P2

P2

P3

P4

P5

P1

P2

P4

P5

Total average waiting time=50.0 Average turnaround time=58.4 According to SRT algorithm: GANTT chart

P3 P2

P4 P2

P4 P2

P1

P1

P5

P2

P5

P5

Total average waiting time=26.4 Average turnaround time= 44.6 Example IInd Suppose RR time quantum =5 Table 2.

Processes Burst time in (ms) P1 24 P2 20 P3 8 P4 10 P5 3 According to simple Round-Robin Algorithm: GANTT chart

P1 P1

P2 P2

P3 P1

P4 P2

P5 P1

P1

P2

P3

P4

Volume 2, Issue 2 March April 2013

Page 112

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)


Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 2, Issue 2, March April 2013 ISSN 2278-6856
[4.] 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, Vol 6, No. 10, 2009. [5.] Englander, I., 2003. The Architecture of Computer Hardware and Systems Software; An Information Technology Approach, 3rd Edition, John Wiley & Sons, Inc., [6.] Operating Systems Sibsankar Haldar 2009, Pearson Education, India. [7.] D. M. Dhamdhere Operating Systems A Concept Based Approach, Second edition, Tata McGraw-Hill, 2006 [8.] Ajit Singh, Priyanka Goyal, Sahil Batra, An Optimized Round Robin Scheduling Algorithm for CPU Scheduling, (IJCSE) International Journal on Computer Science and Engineering Vol. 02, No. 07, 2010, 2383-2385. [9.] Sabrina, F.C.D, Nguyen, S.Jha, D. Platt and F. Safaei, 2005. Processing resources scheduling in programmable networks. Computer commun, 28:676-687. [10.] Sunita Mohan,Mixed Scheduling (A New Scheduling Policy), Proceedings of Insight09, 2526 November 2009. AUTHORS PROFILE Neeraj Kumar received the degree Master of Technology in Computer Science & Engineering in 2000. He is an Assistant Professor & Head in CSE at Institute of Technology Roorkee, Roorkee. His interests are in Operating System, Image Processing & Neural Networks. Nirvikar received the degree Master of Technology in Computer Science & Engineering. He is an Assistant Professor in MCA department at IEC College of Engineering, Greater Noida. His interests are in Operating System, Data Structure & Computer Networks.

Total average waiting time=33.2 Average turnaround time=45.2 According to SRT algorithm: GANTT chart

P5 P2

P3 P2

P3 P1

P4 P1

P4 P1

P2

P1

P2

P1

Total waiting time=17.2 Average turnaround time=30.02

5. CONCLUSION
As we know that RR is a useful algorithm for time sharing system and we have compared both the simple RR and SRT algorithms and observed that the average waiting time, average turnaround time is less in SRT so it is more efficient as compared to simple RR so for better performance we can use SRT in time sharing systems. REFERENCES

[1.] Silberschatz, Galvin and Gagne, Operating systems


concepts, 8th edition, Wiley, 2009.

[2.] Stallings,W., 1996. Computer Organization and


Architecture; Designing for Performance, Fourth Edition, Prentice Hall. [3.] Samih M. Mostafa, S. Z. Rida, Safwat H. Hamad, Finding Time Quantum Of Round Robin Cpu Scheduling Algorithm In General Computing Systems Using Integer Programming, International Journal of Research and Reviews in AppliedSciences (IJRRAS), Vol 5, Issue 1, 2010. Volume 2, Issue 2 March April 2013 Page 113

Potrebbero piacerti anche