You are on page 1of 5

An Improved Priority Scheduling Algorithm Using

Time Slice to Minimize Response Time

Aspen Olmsted
Department of Computer Science
College of Charleston
Ahana Roy Charleston, SC, USA
Department of Computer Science olmsteda@cofc.edu
College of Charleston
Charleston, SC, USA
roya@g.cofc.edu

Abstract—Operating system handles a variety of functions − Throughput: number of processes that complete their
such as process management, resource allocation, memory
management, networking, file management to name few. Out of execution per time unit
these tasks, resource allocation is of utmost importance. The
currently existing algorithms have some problems associated with − Turnaround time: interval from submission time of a
them. Some of them can lead to endless waiting or starvation and process to completion time
some of them like round robin has problem of too many context
switches and high waiting time. The sole aim of this paper is to − Waiting time: amount of time a process has been
develop an improvement to existing priority scheduling waiting in the ready queue
algorithm used for scheduling in interactive systems. The
proposed algorithm not only reduces overhead of swapping − Response time: amount of time it takes from when a
priorities but also response/waiting times. request was submitted until the first response is
produced
Keywords—CPU scheduling, CPU utilization, Throughput,
Turnaround time, Waiting time, Response time, Context switch rate, With a priority scheduler, the scheduler simply picks the
Priority scheduling algorithm, Starvation, CPU burst, Gantt chart highest priority process to run. If the system uses preemptive
scheduling, a process is preempted whenever a higher priority
I. INTRODUCTION process is available in the run queue. Priorities may also be
Scheduling forms the basis of multi-programmed operating static or dynamic. A process with a static priority keeps that
systems. It is because scheduling determines which processes priority for the entire life of the process. A process with a
run when there are multiple runnable processes. dynamic priority will have that priority changed by the
scheduler during its course of execution. The scheduler would
Scheduling algorithm improves processor’s efficiency by do this to achieve its scheduling goals. For example, the
improving its utilization. First Come, First Serve (FCFS) [1], scheduler may decide to decrease a process’ priority to give a
Shortest Job First (SJF) [1] [2], Shortest Remaining Time First chance for lower-priority job to run. If a process is I/O bound
(SRTF) [1], Round Robin (RR) [1] [3], Highest Response (spending most of its time waiting on I/O), the scheduler may
Ratio Next (HRRN), Mid Average Round Robin (MARR) [4], give it a higher priority so that it can get off the run queue
Adaptive Round Robin (Adaptive RR) [5], Improved Round quickly and schedule another I/O operation. Static and
Robin Approach using Dynamic Time Quantum (IRRADTQ) dynamic priorities can coexist. A scheduler would know that a
[6] and Varying Response Ratio Priority (VRRP) [7] are some process with a static priority cannot have its priority adjusted
of the examples of scheduling algorithms. As performance of throughout the course of its execution. Ignoring dynamic
the algorithm may vary under various situations [2], so the priorities, the priority scheduling algorithm is straightforward:
possible criteria for selection of a proper algorithm can be each process has a priority number assigned to it and the
reduced context switch count, increased throughput, increased scheduler simply picks the process with the highest priority
processor use, reduced waiting time, reduced response time [1].
and reduced turnaround time [8]. To choose the best and
appropriate algorithm we need to focus on following criteria In this paper, we will be handling indefinite blocking (or
[1]: starvation), a major problem in priority scheduling algorithms.
A process that is ready to run but lacking the CPU can be
− CPU Utilization: our main goal is to keep the CPU as considered blocked-waiting for the CPU [1]. A priority
scheduling algorithm can leave some low-priority processes
busy as possible
waiting indefinitely for the CPU. One approach to this
problem of indefinite postponement is to use dynamic process with highest instantaneous priority is allocated to the
priorities. At the expiration of each quantum, the scheduler processor. From the results of the study, the authors inferred
can decrease the priority of the current running process that CEHIPN will never lead to starvation and has much better
(thereby penalizing it for taking that much CPU time). results in terms of average waiting time, average response
Eventually its priority will fall below that of the next highest time, when compared with FCFS, SJF, RR, Highest Response
process and that process will be allowed to run. Another Ratio Next, Varying Response Ratio Priority, Mid Average
approach is to have the scheduler keep track of low priority Round-Robin and Adaptive Round Robin.
processes that do not get a chance to run and increase their
priority so that eventually the priority will be high enough so Lottery scheduling solves the problem of starvation [3].
that the processes will get scheduled to run. Once it runs for its Processes are each assigned some number of lottery tickets,
quantum, the priority can be brought back to the previous low and the scheduler draws a random ticket to select the next
level. This periodic boosting of a process’ priority to ensure it process to be executed. Giving each process at least one
gets a chance to run is called process aging [1]. lottery ticket guarantees that it has non-zero probability of
being selected at each scheduling operation. On average, CPU
The rest of the paper is organized as follows. Section II time is proportional to the number of tickets given to each job.
and III discusses relative work and our proposed algorithm To avoid starvation, every job gets at least one ticket. Thus,
respectively. In Section IV and V, implementation and lottery scheduling can be used to solve problems involving fair
corresponding results are shown. Finally, we conclude and share of CPU [18].
discuss future work in Section VI.
In Standard Deviation based CPU scheduling [19], a queue
II. RELATED WORK is maintained in which processes are ordered based on the
burst time value proximity with the value of the standard
The major drawback associated with First Come, First deviation. Process whose burst time is closest to the standard
Serve (FCFS) [1] scheduling algorithm is that being a deviation value will be executed first.
non-preemptive approach it waits for a less important
time-consuming process to finish first. To overcome this III. HYPOTHESIS
problem Shortest Job First (SJF) algorithm was proposed in
which the job with shorter burst time is executed first [1] [3]. Our hypothesis is an improvement to existing enhanced
But in this approach if short processes keep coming in priority scheduling algorithm [20]. Our purpose is to achieve
sequence, then any long process must wait endlessly for its the following objectives:
chance and may starve [9]. A new algorithm was proposed − maximized CPU utilization
Shortest Remaining Time First (SRTF) [1]. This is a
preemptive approach in which job with shorter remaining time
− maximized throughput
is executed first. Again, problem was the same, if new jobs
with shorter running time keep coming then an older job with
larger remaining time must wait endlessly creating a condition − minimized (average) turnaround time
of starvation.
− minimized (average) waiting time
To overcome starvation, a new algorithm Round Robin
(RR) was introduced [1] [3]. In this approach processor − minimized (average) response time
handles each process in recurring order and for a fixed time
quantum. Hence each process gets the processor equally and − minimized context switch rate
no process ever starves. But because of these frequent
switching RR is associated with many context switches and − fairness of resource allocation
high average waiting time [10]. To further reduce the average
waiting time, many improvements over round-robin algorithm We propose an algorithm which aids in minimizing
were proposed [11] [12] [13]. Like Proportional Share some of the above performance parameters such as
scheduling algorithm, which was proposed by Helmy and response time, waiting time for lower priority processes
Dekdouk [14], this algorithm inherits features from ensuring each process is given a fair chance to access
round-robin and is encouraging for shorter jobs. Shortest resources.
Remaining Burst Round Robin (SRBRR) scheduling
algorithm assigns the processor to processes with shortest Step 1: The tasks are sorted according to their priorities.
remaining burst in round robin manner using the dynamic time Lower numbers are used to represent higher priorities. The
quantum [15]. Priority Based Dynamic Round Robin process with the highest priority is allocated first and those
(PBDRR) algorithm uses intelligent time slice and holds with the same priorities are scheduled by FCFS policy.
features from Priority algorithm and Round Robin [16]. Step 2: Allocate all sorted process to CPU for a
Researchers proposed another novel approach; a predetermined time slice. Value of time slice = (process
preemptive priority base scheduling algorithm namely with shortest burst time + process with largest burst
Chronically Evaluated Highest Instantaneous Priority Next time)/2
(CEHIPN) [17]. This algorithm takes the instantaneous Step 3: After all the processes have been executed once
remaining time and waiting time of the processes into using the given time slice, instead of symmetrical
consideration to calculate their instantaneous priority. Then the
swapping of process priorities [20], allocate the incomplete Scheduling) (in
processes a new value of time slice = average of remaining sec)
burst times.
P5 0 0
Step 4: Repeat step 3 until the completion of execution of
all processes in the queue. P3 97 62.5

IV. IMPLEMENTATION P2 129 94.5


To aid illustrate our hypothesis, let’s demonstrate a specific P1 221 157
case. We have assumed arrival time of all processes is zero.
P4 312 219.5
Process Priority Burst time Table 3: Data to plot bar chart, a comparison of response times
P1 6 91 V. RESULTS
P2 4 92 According to Figure 1 and the outcome of our
P3 3 32 implementation, it is observed that:
− response time for individual process is greatly
P4 7 28
reduced (Table 3)
P5 1 97
− timely resource allocation is ensured to all
Table 1: Case study with five processes processes and hence the problem of indefinite
postponement is tackled
According to simple priority scheduling algorithm:
− fair treatment of all process is ensured due to the
Gantt chart: introduction of the concept of time slice along
P5 P3 P2 P1 P4 with priority
0 97 129 221 312 340 − waiting time for the lowest priority process is
minimized. P4 with lowest priority of 7 (Table 1)
According to our hypothesis:
has a much lesser waiting time of 219.5 seconds
Step 1: Time slice (in seconds) = (97+28)/2 = 62.5 sec when compared to 312 seconds (Figure 1)
Step 2: We run each process for a time slice of 62.5 sec − context switch rate is higher in our hypothesis
Cycle 1: when compared to simple priority scheduling
algorithm (Table 2)
P5 P3 P2 P1 P4
0 62.5 94.5 157 219.5 247.5

Status after step 2: P3, P4 completed


Step 3: Now we calculate the average of burst times of the
remaining processes P1, P2 and P5 or (91+92+97)/3 = floor
(93.33) = 93.
Cycle 1 (4 context switches) + 3 more context switches:
P5 P2 P1
0 93 185 276

Status after step 3: P2, P1 completed


Scheduling Algorithm Context Switch
Figure 1: Comparison of Response Time of Priority Scheduling
Priority 4 (PS) algorithm and proposed hypothesis

Hypothesis 7 VI. CONCLUSIONS AND FUTURE WORK


Table 2: Comparison of context switch rate of simple priority and Our intent is primarily the same as that of the
proposed priority scheduling algorithm enhanced priority algorithm [20], however the difference is in
the approach. We propose an alternative to the step where
Process Response Time Response Time processes are swapped symmetrically in order to prevent low
(Priority (hypothesis) (in priority processes starving to death. Our proposed hypothesis
sec) of calculating the average of burst time for the time slice value
avoids the overhead of swapping (highest priority process with
that of lowest priority) making the scheduling process less the 6th Jordanian Inr. Electrical and Electronics Eng.
time consuming. Also, considering processes are assigned Conference, Jordan, 2006.
static priorities, our approach retains the original priority order [10] R. Yadav, A. Mishra, N. Prakash and H. Sharma, "An
of execution. Improved Round Robin Scheduling Algorithm for CPU
Though we were unable to achieve a reduced context Scheduling," International Journal on Computer Science
switch rate compared to priority scheduling algorithm, still we and Engineering, vol. 2, pp. 1064-1066, 2010.
achieved minimization of response time and degree of [11] A. Singh, P. Goyal and S. Batra, "An Optimized Round
starvation. Besides, fair treatment to all resources and timely Robin Scheduling Algorithm for CPU Scheduling,"
resource allocation (independent of the burst time) to International Journal on Computer Science and
individual process, the proposed algorithm clearly shows Engineering, vol. 2, pp. 2383-2385, 2010.
maximum CPU utilization and efficient handling of resources
[12] A. Noon, A. Kalakech and S. Kadry, "A New Round Robin
provided the burst time of all other processes is less than the
Based Scheduling Algorithm for Operating Systems:
mean of burst time of shortest and largest process.
Dynamic Quantum Using the Mean Average," International
In future, not only do we intend to extend this
Journal of Computer Science Issues, no. 8, pp. 224-229,
research looking for ways to reduce context switch rate but
2011.
also study the effect of implementing the proposed algorithm
to improve the efficiency of time sharing and interactive [13] H. Behera, B. Swain, A. Parida and G. Sahu, "A New
systems along with an assigned priority. Proposed Round Robin with Highest Response Ratio Next
(RRHRRN) Scheduling Algorithm for Soft Real Time
Systems," International Journal of Engineering and
Advanced Technology, no. 37, pp. 200-206, 2012.
[14] T. Helmy and A. Dekdouk, "Burst Round Robin as a
VII. REFERENCES Proportional-Share Scheduling Algorithm," in Proceedings
of the 4th IEEE-GCC Conference on Towards
[1] A. Silberschatz, P. Galvin and G. Gagne, Operating System Techno-Industrial Innovations, Bahrain, 2007.
Concepts (Vol. 6), Hoboken: Wiley, 2001. [15] R. B. H. P. K. a. D. M. Mohanty, "Design and Performance
[2] E. Oyetunji and A. Oluleye, "Performance Assessment of Evaluation of a New Proposed Shortest Remaining Burst
Some CPU Scheduling Algorithms," Research Journal of Round Robin (SRBRR) Scheduling Algorithm," in
Information and Technology, vol. 1, pp. 22-26, 2009. Proceedings of International Symposium on Computer
Engineering & Technology (ISCET), 2010.
[3] A. S. Tanenbaum and H. Bos, Modern Operating Systems
Pearson Prentice-Hall, 2015. [16] R. Mohanty, H. Behera, K. Patwari, M. Dash and M.
Prasanna, "Priority Based Dynamic Round Robin (PBDRR)
[4] P. Banerjee, P. Banerjee and S. Dhal, "Comparative
Algorithm with Intelligent Time Slice for Soft Real Time
Performance Analysis of Mid Average Round Robin
Systems," International Journal of Advanced Computer
Scheduling (MARR) Using Dynamic Time Quantum with
Science and Applications, no. 2, pp. 46-50, 2011.
Round Robin Scheduling Algorithm Having Static Time,"
International Journal of Electronics and Computer Science [17] A. Pandey, P. Singh, N. Gebreegziabher and A. Kemal,
Engineering, vol. 1, pp. 2026-2034, 2012. "Chronically Evaluated Highest Instantaneous Priority Next:
A Novel Algorithm for Processor Scheduling," Journal of
[5] S. Hiranwal and K. Roy, "Adaptive Round Robin
Computer and Communications, vol. 4, pp. 146-159, 2016.
Scheduling Using Shortest Burst Approach, Based on Smart
Time Slice," International Journal of Computer Science and [18] Y. Adekunle, Z. Ogunwobi, S. A. Jerry, B. Efuwape, S.
Communication, vol. 2, pp. 319-323, 2011. Ebiesuwa and J.-P. Ainam, "A Comparative Study of
[6] S. Negi, "An Improved Round Robin Approach Using Scheduling Algorithms for Multiprogramming in Real-Time
Dynamic Time Quantum for Improving Average Waiting Systems," International Journal of Innovation and Scientific
Time," International Journal of Computer Applications, no Research, vol. 12, no. 1, pp. 180-185, 2014.
69, pp. 12-16, 2013. [19] D. K. S. Kaswan and Amandeep, "A New Technique For
[7] P. Singh, A. Pandey and A. Mekonnen, "Varying Response CPU Scheduling: Standard Deviation Based," International
Ratio Priority: A Preemptive CPU Scheduling Algorithm Journal of Advanced Research in Computer Engineering &
(VRRP)," Journal of Computer and Communications, vol Technology (IJARCET), vol. 6, no. 8, pp. 1278-1282, 2017.
3, no. 40, 2015. [20] S. Tyagi, S. Choudhary and P. Akshant, "Enhanced Priority
[8] I. Rajput and D. Gupta, "A Priority Based Round Robin Scheduling Algorithm to minimise Process Starvation"
CPU Scheduling Algorithm for Real Time Systems," International Journal of Emerging Technology and
International Journal of Innovations in Engineering and Advanced Engineering, vol. 2, no. 10, pp. 288-294, 2012.
Technology, vol. 1, pp. 1-11, 2012. [21] W. Stallings, Operating Systems, New York: Pearson
[9] B. Shahzad and M. Afzal, "Optimized Solution to Shortest Education, 2009.
Job First by Eliminating the Starvation," in Proceedings of
[22] S. Negi and P. Kalra, "A Comparative Performance Analysis [24] M. Saliu and K. Salah, "Starvation Problem in CPU
of Various Variants of Round Robin Scheduling Algorithm," Scheduling For Multimedia Systems," 15 May 2014.
International Journal of Information & Computation [Online]. Available:
Technology, no. 4, pp. 765-772, 2014. https://www.researchgate.net/publication/228703327.
[23] S. Jain and D. S. Jain, "A Review Study on the CPU [25] I. Abdullahi, "Process Scheduling In Longest Job First (LJF)
Scheduling Algorithms," International Journal of Advanced Algorithm: A Propose framework for starvation problem,"
Research in Computer and Communication Engineering January 2012. [Online]. Available:
vol. 5, no. 8, pp. 22-31, 2016. https://www.researchgate.net/publication/278783147.

You might also like