International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)288
Enhanced Priority Scheduling Algorithm to minimise Process
Starvation
Siddharth Tyagi
1, Sudheer Choudhary
2, Akshant Poonia
3 1,2,3B.Tech IT,VIT University, Vellore, India
Abstract — The primary objective of this paper is to develop an enhanced approach for existing Priority Scheduling algorithm. The proposed approach greatly helps in minimizing the Response time thereby reducing the waiting time for lowest priority processes. Operating system handles a variety of functions such as process management, resource
allocation, memory management, networking, file
management etc. In all these tasks Resource allocation is of utmost importance.
Many scheduling techniques(e.g. Priority, First Come First Serve, Shortest Job First)are available, but to choose the best and appropriate algorithm we need to focus on certain characteristics and features like Context Switch rate, Average waiting time, Response time, Average turn around time and degree of starvation. The proposed algorithm greatly reduces the existing Priority Scheduling architecture in terms of degree of starvation of lower priority processes. The approach adjusts the existing performance parameters to an optimal level thereby yielding efficient results for a specific set of cases. In this paper, we have also made a comparative study of the existing technique as well as the proposed approach to illustrate significant difference in performance parameters.
Keywords — CPU scheduling, PR scheduling algorithm, Turnaround time,Waiting time, Response time,Context switch rate, Gantt chart
I. INTRODUCTION
In computer science, scheduling is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). This is usually done to load balance a system effectively or achieve a target quality of service.
Scheduling forms the basis of multiprogrammed operating systems. It is because scheduling determines which processes run when there are multiple runnable processes. Since multitasking forms the basis of modern day computing, the need for a scheduling algorithm is of utmost importance.
The scheduleris concerned mainly with [7]:
▪CPU utilization - to keep the CPU as busy as possible.
▪Throughput - number of processes that complete their execution per time unit.
▪Turnaround - total time between submission of a process and its completion.
▪Waiting time - amount of time a process has been waiting in the ready queue.
▪Response time - amount of time it takes from when a request was submitted until the first response is produced.
▪Fairness - Equal CPU time to each thread.
In practice, these goals often conflict (e.g. throughput versus latency), thus a scheduler will implement a suitable compromise. Preference is given to any one of the above mentioned concerns depending upon the user's needs and objectives [1].
Since CPU scheduling is one of the most important CPU tasks, therefore its scheduling is central to operating system design.
According to Silberchatz, Galvin and Gagne [5], in case of multi-programmed operation system CPU scheduling plays a fundamental role by switching the CPU among various processes. The aim of the operating system should be to allow a number of processes to run concurrently to maximize CPU utilization.
According to Sabrina, F.C.D, Nguyen, S.Jha, D. Platt and F. Safaei [4] Scheduling is a fundamental operating system function. Almost all computer resources are scheduled before use. CPU scheduling is certainly of primary concern as it has a very deep impact on resource utilization and other performance parameters. Thus, the main goal of the programmers/designers should be to come up with such scheduling policies that significantly help in improving the performance parameters and optimum utilization of available resources.
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)289 II. SIMPLE (PR)PRIORITY SCHEDULING ALGORITHM
According to Silberchatz, Galvin, Gagne in operating system design and operating system by D M Dhamdhere, the simple RR scheduling algorithm is given by following steps:-
1. The scheduler maintains a queue of ready processes and a list of blocked and swapped out processes.
2. The PCB of newly created process is added to end of ready queue. The PCB of terminating process is removed from the scheduling data structures.
3. The scheduler always selects the PCB at head of the ready queue.
4. Priority is associated with each process. The process with the highest priority is serviced first followed by lower priority process
5. The event handler perform the following action
a) When a process makes an input -output request or swapped out, its PCB is removed from ready queue to blocked/swapped out list.
b) When input-output operation awaited by a process finishes or process is swapped in its process control block is removed from blocked/swapped list to end of ready queue.
III. SCHEDULING OBJECTIVES
Since we expect the system to work for the user process, naturally it will be better, if it is very efficient. To make better use of the resources we go for scheduling so that work takes place in a controlled fashion. In simple words, the objective of Scheduling is to optimize the system performance. A system designer must consider a variety of factors when developing a scheduling discipline, such as what type of systems and what are user's needs. Depending on the system, the user and designer might expect the scheduler to:
Better Rationing of Resources for better control and co-ordination
Fair Treatment to all the processes
Providing Service to maximum number of users at a given time
Give room for inter-activeness
Minimize the overhead i.e. the wastage of resources
Provide room for priorities when necessary
Efficient utilization of the CPU
Increase the level of CPU utilization, thereby providing a very high degree of Multiprogramming
Achieve a Balance in the usage of Resources
Should not crack or buckle under heavy workload (i.e.) prevent overload or for a heavy workload provide services at an accepted level
Provide good response
A system can accomplish these goals in several ways. The scheduler can prevent indefinite postponement of processes through aging. The scheduler can increase throughput by favoring processes whose requests can be satisfied quickly, or whose completion frees other processes to run.
IV. SCHEDULING CRITERIA
Since each scheduling algorithm has different properties of its own a question naturally arises. How to choose the best and appropriate algorithm? So to make such a selection, a comparison must be made between them, and for comparing them, certain characteristics and features, which are common and which can determine the best algorithm, need to be taken into account. So for this purpose certain desirable criteria are naturally considered.
They are-
Response Time:Once the processes are given in the CPU, the time taken to start providing the response to the submitted process is Response Time. Large response time is a drawback in Priority scheduling architecture as it leads to degradation of system performance.
Fair Treatment to all process: Fair treatment means lower priority processes should not be subjected to indefinite postponement waiting for higher priority process to complete their execution as a whole.
Throughput: Throughput is defined as the amount of work completed per unit time. It can be expressed as
Throughput=No. of jobs completed/Total time required to compete the jobs
Turnaround Time: Turnaround time is time interval from the time of submission of a process to the time of its completion. It may be calculated as the sum of periods spent in the system (i.e.to get into memory, waiting in the ready queue, CPU time and I/O operations).
Waiting Time: Waiting time is the sum of periods; the process spends, only waiting in the Ready Queue.
Waiting Time=Turnaround Time-Processing Time
So we can conclude that a good scheduling algorithm for real time and time sharing system must possess following characteristics:
Response time should be minimum.
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)290
Context switches should be minimum.
CPU utilization should be maximum.
Throughput should be maximum.
Turnaround time should be minimum.
Waiting time should be minimum.
V. PROPOSED PRIORITY SCHEDULING ALGORITHM
The proposed algorithm will be executed in the following steps which help to minimize performance parameters such as response time, waiting time for lower priority processes and ensures that each process is given a fair chance to access resources
Step1: The tasks are sorted according to their priorities. Lower numbers are used to represent higher priorities. The process with the highest priority is allocated first and those with the same priorities are scheduled by FCFS policy.
Step 2: Allocate all sorted process to CPU for a predetermined time slice. Value of time slice= (Burst time of shortest process+Burst time of largest process)/2
Step3: After all the processes have been executed once using the given time slice, swap the process priorities symmetrically with other process as shown below:
Suppose there are 6 processes say P1,P2,P3,P4,P5,P6 where priority of P1 is 1;P2 is 2; P3 is 3; P4 is 4; P5 is 5; P6 is 6,so swapping takes place symmetrically as follows:
P1 P2 P3 P4 P5 P6
Suppose there are only 5 processes say P1,P2,P3,P4,P5 where P1 has highest priority and P5 has least priority and process are arranged in descending order of priorities as the previous case, then swapping takes place as follows:
P1 P2 P3 P4 P5
The priority of P3 remains undisturbed as there is no symmetric process for P3 to swap with.
It is to be noted that the process which complete their execution within the initial time slice itself are not taken into account for priority swapping.
VI. CASE STUDIES
For illustrating the above process we discuss a number of experiments. In all the experiments arrival time of all processes is zero. The response time, number of context switches, average waiting time, and average turnaround time has been calculated and the results were compared.
Experiment1: In this we consider the processes with CPU burst time and following processes are given:
Process Priority Burst time
P1 6 91
P2 4 67
P3 3 32
P4 7 28
P5 1 97
According to the simple Priority algorithm:
Gantt chart:
P5 P3 P2 P1 P4
0 97 129 196 287 315
According to proposed Priority algorithm:
Time slice=(97+28)/2=62.5 s
Thus, we need to run each process for a time slice of 62.5 s
Cycle 1:
P5 P3 P2 P1 P4
0 62.5 94.5 157 219.5 247.5
Status after cycle1:
P3 completed; P4 completed Swapping is as follows:
P5 P2 P1
P2 remains unswapped.
So the order of execution would be P1, P2, P5
P5 P3 P2 P1 P4 P1 P2 P5
0 62.5 94.5 157 219.5 247.5 276 280.5 315
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)291 Algorithm Avg Turn
Around Time
Avg Waiting Time
Context Switch
Priority Scheduling
204 141.8 s 4
Proposed Priority Scheduling
256.5 179.7 7
Comparative study of Average waiting time and Average turn around time in both cases
Process Response time through Priority Scheduling
Response time through Proposed Priority
Scheduling
P5 0 0
P3 97 62.5
P2 129 94.5
P1 196 157
P4 287 219.5
Comparative study of Response time in both cases
Least Priority Process
Waiting Time through Priority Scheduling
Waiting Time through
Proposed Priority Scheduling
P4 287 219.5
Comparative study of Waiting time for least priority process
0 50 100 150 200 250 300 350
P5 P3 P2 P1 P4
R
ES
PO
N
SE
T
IM
E
PROCESS ID
RTPS RTPPS
Fig.1Comparison of response time of priority scheduling and proposed priority scheduling (RTPS: Respose time for priority scheduling; RTPPS: Response time for proposed priority scheduling)
Throughput in PS Throughput in PPS
5/315=0.0158 5/315=0.0158
Comparative study of Throughput in both cases PS-Priority Scheduling
PPS-Proposed Priority Scheduling
Experiment 2:
In this case we consider the following processes with CPU burst time as shown
Process ID Priority Burst Time
P3 1 38
P1 2 49
P4 3 54
P2 4 60
P5 5 63
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)292
Gantt chart:
P3 P1 P4 P2 P5
0 38 87 141 201 264
According to proposed priority algorithm: Time slice= (38+63)/2=50.5 s
Cycle 1:
P3 P1 P4 P2 P5
0 38 87 137.5 188 238.5
Status after cycle 1: P3 completed, P1 completed Swapping is as follows:
P4 P2 P5
P2 remains unswapped
P3 P1 P4 P2 P5 P5 P2 P4
0 38 87 137.5 188 238.5 251 260.5 264
Algorithm Avg Turn Around Time
Avg Waiting Time
Context Switch
Priority Scheduling
146.2 93.4 4
Proposed Priority Scheduling
180.1 127.3 7
Comparative study of Average waiting time and Average turn around time in both cases
Process Response time through Priority Scheduling
Response time through Proposed Priority
Scheduling
P3 0 0
P1 38 38
P4 87 87
P2 141 137.5
P5 201 188
Comparative study of Response time and Response time in both cases
Least Priority Process
Waiting Time through Priority Scheduling
Waiting Time through
Proposed Priority Scheduling
P5 201 188
Comparative study of Waiting time for least priority process in both cases
0 50 100 150 200 250
P3 P1 P4 P2 P5
R
ES
PO
N
SE
T
IM
E
PROCESS ID
RTPS RTPPS
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)293 Throughput in PS Throughput in PPS
5/ 264=0.0189 5/264=0.0189
Comparative study of Throughput in both cases PS-Priority Scheduling
PPS-Proposed Priority Scheduling
Experiment3: In this we have to consider the following processes with CPU burst time as shown:
Process ID Priority Burst time
P1 1 60
P2 4 1
P3 3 30
P4 2 25
P5 7 30
P6 8 28
According to simple priority algorithm:-
Gantt Chart:
P1 P4 P3 P2 P5 P6
0 60 85 115 116 146 174
According to proposed priority algorithm: Time slice=(60+1)/2=30.5 s
Cycle 1:
P1 P4 P3 P2 P5 P6
0 30.5 55.5 85.5 86.5 116.5 144.5
Status after cycle 1: Only P1 unfinished
P1 P4 P3 P2 P5 P6 P1
0 30.5 55.5 85.5 86.5 116.5 144.5 174
Algorithm Avg Turn Around Time
Avg Waiting Time
Context Switch
Priority Scheduling
139.2 87 5
Proposed Priority Scheduling
132.5 81.44 6
Comparative study of Average waiting time and Average turn around time in both cases
Process Response time through Priority scheduling
Response time through Proposed Priority scheduling
P1 0 0
P4 60 30.5
P3 85 55.5
P2 115 85.5
P5 116 86.5
P6 146 116.5
Comparative study of Response time in both cases
Least Priority Process
Waiting Time through Priority Scheduling
Waiting Time through
Proposed Priority Scheduling
P6 146 114
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 10, October 2012)294 Fig.3 Comparison of response time of priority scheduling and
proposed priority scheduling
Throughput in PS Throughput in PPS
6/174=0.0344 6/174=0.0344
Comparative study of throughput in both cases PS-Priority Scheduling
PPS-Proposed Priority Scheduling
From the results of the above experiments it is clearly seen that:
Response time for individual process is greatly reduced
Lowest priority processes is prevented from starvation
Timely resource allocation is ensured to all processes and hence the problem of indefinite postponement is tackled
Fair treatment of all process is ensured due to the introduction of the concept of time slice along with priority
Waiting time for the lowest priority process is minimized
VII. CONCLUSION
We made a comparative study of simple Priority algorithm and Proposed Priority algorithm. It is concluded that the proposed algorithm is superior in terms of Response time, minimising degree of starvation, fair treatment to all resources and timely resource allocation (independent of the burst time) to individual process. The proposed algorithm clearly shows maximum CPU utilization and efficient handling of resources provided the burst time of all other processes is less than the mean of burst time of shortest and largest process. In the near future this enhanced Priority scheduling algorithm can be implemented effectively to improve the efficiency of Time sharing and Interactive systems along with an assigned priority.
REFERENCES
[1] http://en.wikipedia.org./wiki/scheduling
[2] Operating Systems Sibsankar Haldar 2009,Pearson Education, India [3] D.M. Dhamdhere operating Systems A Concept Based
Approach,Second edition, Tata McGraw-Hill, 2006.
[4] Sabrina, F.C.D, Nguyen, S.jha, D. Platt and F. Safaei,2005.Processing scheduling in programmable networks. Computer commun, 28:676-687.
[5] Silberchatz, Galvin and Gagne, 2003. Operating systems concepts. [6] S.Sredharran,Operating Systems,2000 ISBN 81-87721-18-9 [7] IJRRAS 5 (1) ● October 2010 Mostafa & al. ● Finding Time