an optimal mathematical approach for cpu scheduling ...cpu scheduling algorithms and an optimal...

16
International Journal of Computational and Applied Mathematics. ISSN 1819-4966 Volume 12, Number 1 (2017), pp. 65-80 © Research India Publications http://www.ripublication.com An Optimal Mathematical Approach for CPU Scheduling OMDRRS vs. RR Neetu Goel Research Scholar Department of Computer Science, TMU, India Dr. Abhinav Saxena Assistant Professor Department of Mathematics, TMU, India. Dr. R. B. Garg Ex- Professor, Delhi Universty, India. Abstract Prime objective of this paper is to estimate turnaround time, waiting time and context switch of any process in CPU scheduling mathematically. CPU scheduling has an esteemed impact on utilization of resources and total quality of the system. The management of processes in the scheduling of CPU is based on various algorithms. The Round Robin scheduling algorithm is relatively better than other existing CPU scheduling algorithm. In this paper CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has been presented. Based on the experiments executed and results generated by the simulator on a data set of 50 processes, it has been proved that in comparison to the conventional round robin algorithm, OMDRRS algorithm increases efficiency of average waiting time by 36%; that of the average turnaround time 35% and that of context switch by 35%.The mathematical approach of Round Robin and OMDRRS algorithm is transparent enough; it provides, for each process, the actual order of shifting of a process and also the order of execution. Keywords: CPU Scheduling, Ready Queue, Burst Time, Turnaround time, Mathematical formulation, Waiting Time and Context Switch

Upload: others

Post on 08-Aug-2021

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

International Journal of Computational and Applied Mathematics.

ISSN 1819-4966 Volume 12, Number 1 (2017), pp. 65-80

© Research India Publications

http://www.ripublication.com

An Optimal Mathematical Approach for CPU

Scheduling – OMDRRS vs. RR

Neetu Goel

Research Scholar

Department of Computer Science, TMU, India

Dr. Abhinav Saxena

Assistant Professor

Department of Mathematics, TMU, India.

Dr. R. B. Garg

Ex- Professor,

Delhi Universty, India.

Abstract

Prime objective of this paper is to estimate turnaround time, waiting time and

context switch of any process in CPU scheduling mathematically. CPU

scheduling has an esteemed impact on utilization of resources and total quality

of the system. The management of processes in the scheduling of CPU is

based on various algorithms. The Round Robin scheduling algorithm is

relatively better than other existing CPU scheduling algorithm. In this paper

CPU Scheduling Algorithms and an optimal mathematical approach using

“Optimum Dynamic Round Robin Scheduling” (OMDRRS) has been

presented. Based on the experiments executed and results generated by the

simulator on a data set of 50 processes, it has been proved that in comparison

to the conventional round robin algorithm, OMDRRS algorithm increases

efficiency of average waiting time by 36%; that of the average turnaround

time 35% and that of context switch by 35%.The mathematical approach of

Round Robin and OMDRRS algorithm is transparent enough; it provides, for

each process, the actual order of shifting of a process and also the order of

execution.

Keywords: CPU Scheduling, Ready Queue, Burst Time, Turnaround time,

Mathematical formulation, Waiting Time and Context Switch

Page 2: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

66 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

I. INTRODUCTION

The primary objective in multiprogramming time-sharing systems is to provide

reasonably good response time and equitably sharing of system resources to all

existing users and hence improving the uni-processor performance. CPU scheduling is

one of the root structures for multi-programming to increase the performance of uni-

processor and implement multitasking concept. Scheduling is a set of policies and

mechanisms, so as to govern the order of work to be carried out by a system. The

scheduling policy determines at what instant a process is to be removed from the CPU

and which process should be allocated to the CPU, waiting in ready queue. According

to the advantages and disadvantages of an existing CPU scheduling algorithms RR is

identified to be the best one [2][5][6]. Round Robin scheduling algorithm is classified

into the preemptive discipline category and is one of the most popular in time slicing

known till now. RR distributes the processing time equally among all processes that

are requesting for the processor. Basically the processor time is divided into slices or

quanta, which are allocated to the requestor. The scheduler then removes this

currently running process from the CPU and selects the next ready job from the ready

list on an FCFS basis. The scheduler only needs to maintain a list of ready processes.

If there is need of more time by the process to complete its execution after it has

exhausted its specified time slice, the CPU is preempted and switched over to another

process.

Response time of RR scheduling algorithm is relatively better, although its

performance is very sensitive to time-slice. If quantum is very short, then the short

processes will move through the system quickly and nicely. But if this quantum is so

selected that it is not very large in comparison to process switching, then this will

invite more overhead of dispatching operations including process switches. To

overcome all such drawbacks which hinder the better performance of CPU

scheduling, new algorithm named OMDRRS “Optimum Multilevel Dynamic Round

Robin Scheduling Algorithm” is proposed [11].This is a preemptive scheduling

algorithm. OMDRRS algorithm calculates dynamic time slice after every round of

execution. The results display robustness of this algorithm. It is an improvement of

popularly implemented RR scheduling algorithm.

In this paper turnaround time, waiting time and context switch of Round Robin

algorithm has been formulated mathematically. It also made an attempt to formulate

the turnaround time and waiting time of the improved algorithm ÓMDRRS. There are

five sections in this paper. Section I projects a brief introduction on the various

aspects of the scheduling algorithm. In section II, we analytically examine the

components of the existing Round Robin algorithm for CPU bound processes. Section

III presents the mathematical approach of improved algorithm. The Section IV,

presents the simulation results of Round Robin and OMDRRS algorithm by

comparison of results obtained by working on different data sets with conventional

Round Robin followed by conclusion and future scope.

Page 3: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 67

\

II. MATHEMATICAL FORMULATION OF CPU SCHEDULING

ALGORITHMS

A. First Come First Serve Algorithm

Let 𝑃1,𝑃2, … … 𝑃𝑛, be n-processes arranged in FCFS manner in a ready queue (to be

referred as RQ), having 𝐵𝑇𝑖 ;i=1,2,3, …,n, as their expected CPU bursts for

completion respectively.

1). Formulation of Total Turnaround Time

Total turnaround time for a process 𝑃𝑖 can be calculated by summing up the total time

spent by the process 𝑃𝑖 in RQ.

Turnaround Time of P1 = 𝐵𝑇1

Turnaround Time of P2 =𝐵𝑇𝐼 + 𝐵𝑇2

Also,

Turnaround Time of Pi =𝐵𝑇𝐼 + 𝐵𝑇2 + ⋯ … … + 𝐵𝑇𝑖

Hence, the following expression is obtained for Pi(TAT)

𝑃𝑖(𝑇𝐴𝑇) = ∑ 𝐵𝑇𝑘𝑖𝑘=1 − 𝐴𝑇𝑖 (1)

Average Turnaround Time of a process Pi can be calculated with the help of following

expression:

Average Turnaround Time= ∑ 𝑃𝑘(𝑇𝐴𝑇)𝑛

𝑘=1

𝑛 (2)

2). Formulation of Total Waiting Time

Total waiting time for a process 𝑃𝑖 (Pi(TWT)) can be calculated by summing up total

time devote the process Pi in the RQ.

Waiting Time of P1 = 0

Waiting Time of P2 = 𝐵𝑇1

Waiting Time of P3 = 𝐵𝑇1 + 𝐵𝑇2

Hence, in general for i process, we have

Waiting Time of Pi = 𝐵𝑇𝑖−1 + 𝐵𝑇𝑖−2 + ⋯ … … 𝐵𝑇1

Hence, the following expression is obtained for Pi(TWT)

𝑃𝑖(𝑇𝑊𝑇) = ∑ 𝐵𝑇𝑘𝑖−1𝑘=1 − 𝐴𝑇𝑖 (3)

Average Waiting Time of a process Pi can be calculated with the help of following

expression:

Average Waiting Time = ∑ 𝑃𝑘(𝑇𝑊𝑇)𝑛

𝑘=1

𝑛 (4)

Page 4: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

68 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

B. Shortest Job First Algorithm

Let 𝑃1,𝑃2, … … 𝑃𝑛, be n-processes which have been arranged in FCFS manner in a

temporary queue (this is referred to as TQ), having 𝐵𝑇𝑖 ; i =1,2,3,…, n as their

expected CPU bursts for completion respectively. Depending upon the burst time

corresponding to each process, the submitted processes are ordered in the ready queue

(referred as RQ). Ready queue is maintained for all process, where n-processes are

arranged in ascending manner () as per their burst time.

𝑅𝑄𝑛 = (𝑃1 ), (𝑃2), … … (𝑃𝑛)

1). Formulation of Total Turnaround Time

Total Turnaround Time for a process 𝑃𝑖 can be calculated by summing up by its total

time devote in the RQ.

Turnaround Time of P1 = 𝐵𝑇1

Turnaround Time of P2 =𝐵𝑇𝐼 + 𝐵𝑇2

Also,

Turnaround Time of Pi =𝐵𝑇𝐼 + 𝐵𝑇2 + ⋯ … … + 𝐵𝑇𝑖

Hence, the following expression is obtained for Pi(TAT)

𝑃𝑖(𝑇𝐴𝑇) = ∑ 𝐵𝑇𝑘𝑖𝑘=1 − 𝐴𝑇𝑖 (5)

Average Turnaround Time of a process Pi can be calculated with the help of following

expression:

Average Turnaround Time= ∑ 𝑃𝑘(𝑇𝐴𝑇)𝑛

𝑘=1

𝑛 (6)

2). Formulation of Total Waiting Time

Total waiting time for a process 𝑃𝑖 (Pi(TWT)) can be calculated by summing up the

total time devote by the process Pi in the RQ.

Waiting Time of P1 = 0

Waiting Time of P2 = 𝐵𝑇1

Waiting Time of P3 = 𝐵𝑇1 + 𝐵𝑇2

Hence, in general for i process, we have

Waiting Time of Pi = 𝐵𝑇𝑖−1 + 𝐵𝑇𝑖−2 + ⋯ … … 𝐵𝑇1

Hence, the following expression is obtained for Pi(TWT)

𝑃𝑖(𝑇𝑊𝑇) = ∑ 𝐵𝑇𝑘𝑖−1𝑘=1 − 𝐴𝑇𝑖 (7)

Page 5: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 69

\

Average Waiting Time of a process Pi can be calculated as follows:

Average Waiting Time = ∑ 𝑃𝑘(𝑇𝑊𝑇)𝑛

𝑘=1

𝑛 (8)

C. Priority Scheduling Algorithm

Let 𝑃1,𝑃2, … … 𝑃𝑛, be n-processes arranged in FCFS manner in a temporary queue

(referred to as TQ), having 𝐵𝑇𝑖and𝑃𝑟𝑖; i=1,2,3,…, n, as their expected CPU burst time

and priority of a process, respectively. Depending upon the priority of a process, the

submitted processes are ordered in the ready queue (referred as RQ). Ready queue is

maintained for all process, where n-processes arranged in ascending manner () as per

their priority.

𝑅𝑄𝑛 = (𝑃1 ), (𝑃2), … … (𝑃𝑛)

1). Formulation of Total Turnaround Time

Total Turnaround Time for a process 𝑃𝑖 can be calculated by summing up the total

time devote by a process Pi in the RQ.

Turnaround Time of P1 = 𝐵𝑇1

Turnaround Time of P2 =𝐵𝑇𝐼 + 𝐵𝑇2

Also,

Turnaround Time of Pi =𝐵𝑇𝐼 + 𝐵𝑇2 + ⋯ … … + 𝐵𝑇𝑖

Hence, the following expression is obtained for Pi(TAT)

𝑃𝑖(𝑇𝐴𝑇) = ∑ 𝐵𝑇𝑘𝑖𝑘=1 − 𝐴𝑇𝑖 (9)

Average Turnaround Time of a process Pi can be calculated by the following

expression:

Average Turnaround Time= ∑ 𝑃𝑘(𝑇𝐴𝑇)𝑛

𝑘=1

𝑛 (10)

2). Formulation of Total Waiting Time

Total waiting time for a process 𝑃𝑖 (Pi(TWT)) can be calculated by summing up the

total time devoted by the process Pi in the RQ.

Waiting Time of P1 = 0

Waiting Time of P2 = 𝐵𝑇1

Waiting Time of P3 = 𝐵𝑇1 + 𝐵𝑇2

Hence, in general for i process, we have

Waiting Time of Pi = 𝐵𝑇𝑖−1 + 𝐵𝑇𝑖−2 + ⋯ … … 𝐵𝑇1

Page 6: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

70 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

Hence, the following expression is obtained for evaluating Pi(TWT)

𝑃𝑖(𝑇𝑊𝑇) = ∑ 𝐵𝑇𝑘𝑖−1𝑘=1 − 𝐴𝑇𝑖 (10)

Average Waiting Time of a process Pi can be calculated by the following expression:

Average Waiting Time = ∑ 𝑷𝒌(𝑻𝑾𝑻)𝒏

𝒌=𝟏

𝒏 (11)

D. Round Robin Scheduling Algorithm

Let 𝑃1,𝑃2, … … 𝑃𝑛, be n-processes arranged in FCFS manner in a ready queue (referred

as RQ), having 𝐵𝑇𝑖 and 𝑘𝑖; i=1,2,3, …, n, as their expected CPU bursts and number of

cycles required for completion, respectively[1]. Further, let TS denote a fixed time

slice in Round Robin scheduling algorithm. 𝑘𝑖 may be calculated using the following

expression.

𝑘𝑖={

𝐵𝑇𝑖𝑇𝑆⁄ , 𝑖𝑓 𝐵𝑇𝑖%𝑇𝑆 = 0

(𝐵𝑇𝑖𝑇𝑆⁄ + 1), 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

Remaining CPU burst-time is updated after every cycle. Let 𝐵𝑇𝑖,𝑗 and 𝑇𝑆𝑖,𝑗 denote

the remaining CPU burst and executed portion of CPU burst, respectively, for the ith

process in jth cycle. Hence, following expression can be used to evaluate the

remaining CPU time requirement of a process Pi in the kth cycle:

𝐵𝑇𝑖,𝑘= 𝐵𝑇𝑖,𝑘−1 - 𝑇𝑆𝑖,𝑘−1

Where 𝑇𝑆𝑖,𝑘−1 can be obtained from the following:

𝑇𝑆𝑖,𝑘−1 ={𝑇𝑆𝑖 𝑖𝑓 𝐵𝑇𝑖,𝑘−1 < 𝑇𝑆

𝑇𝑆, 𝑖𝑓 𝐵𝑇𝑖,𝑘−1 ≥ 𝑇𝑆

1). Formulation of Total Turnaround Time

Total Turnaround Time for a process 𝑃𝑖 that terminates in kth cycle (Pi(TAT)) can be

calculated by summing the total time it devotes in the RQ from first to kth cycle.

Turnaround Time of Pi in cycle 1 = (𝑇𝑆1,1 + 𝑇𝑆2,1 + … … . +𝑇𝑆𝑖,1) (12)

Turnaround Time of Pi in cycle 2 = (𝑇𝑆𝑖+1,1 + 𝑇𝑆𝑖+2,1 + … … . +𝑇𝑆𝑛,1) +

(𝑇𝑆1,2 + 𝑇𝑆2,2 + … … . +𝑇𝑆𝑖,2) (13)

Turnaround Time of Pi in cycle 3 = (𝑇𝑆𝑖+1,2 + 𝑇𝑆𝑖+2,2 + … … . +𝑇𝑆𝑛,2) +

(𝑇𝑆1,3 + 𝑇𝑆2,3 + … … . +𝑇𝑆𝑖,3) (14)

Page 7: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 71

\

Hence, in general for k cycles, we have

Turnaround Time of Pi in cycles k= (𝑇𝑆𝑖+1,𝑘−1 + 𝑇𝑆𝑖+2,𝑘−1 + … … . +𝑇𝑆𝑛,𝑘−1)

+ (𝑇𝑆1,𝑘 + 𝑇𝑆2,𝑘 + … … . +𝑇𝑆𝑖,𝑘) (15)

Summing upequations12 to 15the required expression is given as:

(𝑃𝑖((𝑇𝐴𝑇))) = ∑ 𝑇𝑆𝑘,1 + [ ∑ 𝑇𝑆𝑘,1 + ∑ 𝑇𝑆𝑘,2

𝑖

𝑘=1

𝑛

𝑘=𝑖+1

] + [ ∑ 𝑇𝑆𝑘,2 + ∑ 𝑇𝑆𝑘,3

𝑖

𝑘=1

𝑛

𝑘=𝑖+1

]

𝑖

𝑘=1

+ ⋯ … + [ ∑ 𝑇𝑆𝑘,𝑗−1 + ∑ 𝑇𝑆𝑘,𝑗

𝑖

𝑘=1

𝑛

𝑘=𝑖+1

]

= ∑ 𝑇𝑆𝑘,1 + ∑ 𝑇𝑆𝑘,2 +

𝑛

𝑘=1

… … . + ∑ 𝑇𝑆𝑘,𝑗−1 + ∑ 𝑇𝑆𝑘,𝑗

𝑖−1

𝑘=1

𝑛

𝑘=1

− 𝐴𝑇𝑖

𝑛

𝑘=1

Hence, the following expression is obtained for Pi(TAT)

𝑃𝑖(𝑇𝐴𝑇) = ∑ [∑ [𝑇𝑆𝑘,𝑙]𝑛𝑘=1 ] + ∑ 𝑇𝑆𝑘,𝑗

𝑖𝑘=1 − 𝐴𝑇𝑖

𝑗−1𝑙=1 (16)

Average Turnaround Time of a process Pi can be calculated by the following

expression:

Average Turnaround Time= ∑ 𝑃𝑘(𝑇𝐴𝑇)𝑛

𝑘=1

𝑛 (17)

2). Formulation of Total Waiting Time

Total waiting time for a process 𝑃𝑖 that terminated in kth cycle (Pi(TWT)) can be

calculated by summing up the total time devote it in the RQ [1] from first to kth cycle.

Waiting Time of Pi in 1st cycle = (𝑇𝑆1,1 + 𝑇𝑆2,1 + … … . +𝑇𝑆𝑖−1,1) (18)

Waiting Time of Pi in 2nd cycle = (𝑇𝑆𝑖+1,1 + 𝑇𝑆𝑖+2,1 + … … . +𝑇𝑆𝑛,1) +

(𝑇𝑆1,2 + 𝑇𝑆2,2 + … … . +𝑇𝑆𝑖−1,2) (19)

Waiting Time of Pi in 3rd cycle = (𝑇𝑆𝑖+1,2 + 𝑇𝑆𝑖+2,2 + … … . +𝑇𝑆𝑛,2) +

(𝑇𝑆1,3 + 𝑇𝑆2,3 + … … . +𝑇𝑆𝑖−1,3) (20)

Hence, in general for kth cycle, we have

Waiting Time of Pi in kth cycle= (𝑇𝑆𝑖+1,𝑘−1 + 𝑇𝑆𝑖+2,𝑘−1 + … … . +𝑇𝑆𝑛,𝑘−1)

+ (𝑇𝑆1,𝑘 + 𝑇𝑆2,𝑘 + … … . +𝑇𝑆𝑖−1,𝑘) (21)

Page 8: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

72 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

Summing up equations 18 to 21these will give us required expression:

(𝑃𝑖(𝑇𝑊𝑇)) = ∑ 𝑇𝑆𝑘,1 + [ ∑ 𝑇𝑆𝑘,1 + ∑ 𝑇𝑆𝑘,2

𝑖−1

𝑘=1

𝑛

𝑘=𝑖+1

] + [ ∑ 𝑇𝑆𝑘,2 + ∑ 𝑇𝑆𝑘,3

𝑖−1

𝑘=1

𝑛

𝑘=𝑖+1

]

𝑖−1

𝑘=1

+ ⋯ … + [ ∑ 𝑇𝑆𝑘,𝑗−1 + ∑ 𝑇𝑆𝑘,𝑗

𝑖−1

𝑘=1

𝑛

𝑘=𝑖+1

] − 𝐴𝑇𝑖

= [∑ 𝑇𝑆𝑘,1 − 𝑄𝑇𝑖,1

𝑛

𝑘=1

] + [∑ 𝑇𝑆𝑘,2 − 𝑇𝑆𝑖,2

𝑛

𝑘=1

] + ⋯ … + [∑ 𝑇𝑆𝑘,𝑗−1 − 𝑇𝑆𝑖,𝑗−1

𝑛

𝑘=1

]

+ ∑ 𝑇𝑆𝑘,𝑗

𝑖−1

𝑘=1

− 𝐴𝑇𝑖

Hence, the following expression is obtained for Pi(TWT) (22)

𝑃𝑖(𝑇𝑊𝑇) = ∑ [∑[𝑇𝑆𝑘,𝑙] − 𝑇𝑆𝑖,𝑙

𝑛

𝑘=1

] + ∑ 𝑇𝑆𝑘,𝑗

𝑖−1

𝑘=1

𝑗−1

𝑙=1

− 𝐴𝑇𝑖

Average Waiting Time of a process Pimay be calculated by the following expression:

Average Waiting Time = ∑ 𝑃𝑘(𝑇𝑊𝑇)𝑛

𝑘=1

𝑛 (23)

3). Formulation of Context Switch

Estimation of total number of context switching has been done with the help of ceiling

function⌈⌉. Ceiling function is used to map a real number to the smallest integer that

follows it. In RR approach quantum time is always static and process enters the queue

with their requirement of CPU time. Total number of cycles required for completion

of a particular process is generated by dividing the burst time of a process by quantum

time [2]. Total number of context switch required in Round Robin scheduling may be

evaluated with the help of following equation:

Number of switching of P1 Process = ⌈𝐵𝑇1

𝑇𝑆⌉

Number of switching of P2 Process = ⌈𝐵𝑇2

𝑇𝑆⌉

Hence, in general for n process, we have

Number of switching of PnProcess = ⌈𝐵𝑇𝑛

𝑇𝑆⌉

Total number of Context Switches = ⌈𝐵𝑇1

𝑇𝑆⌉ + ⌈

𝐵𝑇2

𝑇𝑆⌉ + ⋯ . . + ⌈

𝐵𝑇𝑛

𝑇𝑆⌉

Page 9: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 73

\

Hence, following expression is obtained for total number of Context Switches

= ∑ ⌈𝐵𝑇𝑖

𝑇𝑆⌉𝑛

𝑖=1 (24)

III. MATHEMATICAL FORMULATION OF PROPOSED ALGORITHM

(OMDRRS)

Let 𝑃1,𝑃2, … … 𝑃𝑛, be n-processes arranged in FCFS manner in a temporary queue

(referred as TPQ), having 𝐵𝑇𝑖, 𝐴𝑇𝑖 and 𝑃𝑇𝑖; i=1,2,3, …, n as their burst time, arrival

time and priority. These shall form the components of the Factor (FTi). The relation

between all these parameters is defined as -

FTi = 0.2 X BTi + 0.3 X ATi + 0.5 X PTi (25)

Depending upon the evaluated value of factor (FTi) corresponding to each process, the

submitted processes are ordered in the ready queue. The processes are arranged in

ascending manner () as per their factor value in the Ready Queue.

𝑅𝑄𝑖 = (𝑃1 ), (𝑃2), … … (𝑃𝑛) (26)

Let 𝐵𝑇𝑖,𝑗 , 𝑅𝑇𝑖,𝑗 and 𝑄𝑇𝑖,𝑗 denote the actual burst time, remaining CPU burst time

and actual execution time slice for ith process in jth cycle. The expression used to find

out the Dynamic Quantum Time (DQTj) in the jth cycle can be given by:

𝐷𝑄𝑇𝑗=(𝑅𝑇1,𝑗+𝑅𝑇𝑛,𝑗)/2 ; if 𝑅𝑇𝑖,𝑗> 0, i=1,2………n (27)

Where 𝑄𝑇𝑖,𝑗 can be obtained for a process Pi in the jth cycle from the following

equation:

𝑄𝑇𝑖,𝑗 ={𝑅𝑇𝑖 𝑖𝑓 𝑅𝑇𝑖,𝑗−1 < 𝐷𝑄𝑇𝑗

𝐷𝑄𝑇𝑗 , 𝑖𝑓 𝑅𝑇𝑖,𝑗−1 ≥ 𝐷𝑄𝑇𝑗 (28)

After executing portion of CPU time of a process Pi in the jth cycle, requirement of

remaining CPU burst time (𝑅𝑇𝑖,𝑗) of the process is evaluated for the same cycle. This

may be done as given below:

𝑅𝑇𝑖,𝑗= 𝑅𝑇𝑖,𝑗 - 𝑄𝑇𝑖,𝑗 (29)

If RTi,j is 0 for the current process Pi, then it is sent to Output Queue. Otherwise

decision is to be taken whether the current process is to be added into the equation 26

or it is to be executed by the CPU again in the same cycle. This can be evaluated as

given below:

𝑄𝑇𝑖,𝑗 = {𝑅𝑇𝑖 𝑖𝑓 𝑅𝑇𝑖,𝑗 ≤ 𝐷𝑄𝑇𝑗 /2 ; 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 𝑎𝑑𝑑 𝑖𝑛𝑡𝑜 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 26

Hence, equations from 26 to 29are executed till there is a process remaining in the

ready queue. In the first cycle all n processes will be executed by the CPU, so total

number of processes remaining in the ready queue =n

𝑅𝑄1 = n

Page 10: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

74 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

Total number of processes remaining in the ready queue in second cycle = n - number

of processes terminated up to first cycle

𝑅𝑄2=n-𝑡1

also,

Total number of processes remaining to be executed in (j-2) cycle = n- number of

processes terminated up to (j-3) cycle.

𝑅𝑄𝑗−2= n -(𝑡1 + 𝑡2 + ⋯ … . + 𝑡𝑗−3)

Hence, in general for number of processes available in the ready queue in jth cycle,

we have

∑ 𝑅𝑄𝑘𝑗𝑘=1 = n + (n- (𝑡1 + 𝑡2)) + (n-- (𝑡1 + 𝑡2 + 𝑡3)) + …….. +

(n- (𝑡1 + 𝑡2 + ⋯ . . + 𝑡𝑗−1)

𝑅𝑄𝑗 = 𝑛 − ∑ 𝑡𝑖𝑗−1𝑖=1 (30)

1). Formulation of Turnaround Time of OMDRRS Algorithm

The turnaround around time of a process T(Pi) determines the number of time slices

during which CPU was in use from when the process entered into the ready queue till

the time of termination of process Pi,j for the ith process in jth cycle. These time slices

may include the following:

1. All time slices consumed by the Process Pi,j for the ith process in jth cycle.

2. Number of time slices of full quantum consumed for processes other than Pi,j-

1for the ith process in (j-1)th cycle [Pl,m ; l=1(1)n, l≠i and m=1(1) j-1]

3. Number of time slices of full or part quantum consumed in the last cycle of the

processes terminated before Pi , j

In the determination of total turnaround time for the process Pi, we need to identify

the time slices of each of the above category and compute their number. The

expression to calculate total turnaround time of a process is as follows:

Pi(TAT) = CPU time consumed till the termination of Pi – Arrival time of Pi

For category 1: All time slices consumed for the Process Pi that terminated in jth cycle

Turnaround Time of Pi in cycle 1 = 𝑄𝑇𝑖,1

Turnaround Time of Pi in cycle 2 = 𝑄𝑇𝑖,2

Hence, in general for cycle j, we have

Turnaround Time of Pi in cycle j =𝑄𝑇𝑖,1 + 𝑄𝑇𝑖,2 + …. + 𝑄𝑇𝑖,𝑗

C1= ∑ 𝑄𝑇𝑖,𝑘𝑗𝑘=1 (31)

Page 11: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 75

\

For category 2: Number of time slices of full quantum consumed for processes other

than Pi,j-1 for the ith process in j-1 cycle [Pl,m ; l=1(1)n, l≠i and m=1(1) j-1]

Turnaround Time of Processes other than Pi in cycle 1 = 𝑄𝑇(𝑙,1)where l=1(1)n, l≠i

Turnaround Time of Processes other than Pi in cycle 2 = 𝑄𝑇(𝑙,2)where l=1(1)n, l≠i

Hence, in general for cycle j-1, we have

Turnaround Time of Processes other than Pi in cycle j-1=𝑄𝑇(𝑙,1) + 𝑄𝑇(𝑙,2) + ……… +

𝑄𝑇𝑙,𝑚; where l=1(1)n, l≠i and m=1(1) j-1

𝐶2 = ∑ [∑ 𝑄𝑇𝑙,𝑚𝑛(𝑙=1,𝑙≠𝑖) ]

𝑗−1𝑚=1

𝐶2 = ∑ [∑ 𝑄𝑇𝑙,𝑚 − 𝑄𝑇𝑖,𝑚𝑛𝑙=1 ]

𝑗−1𝑚=1 (32)

For category 3: Number of time slices of full or part of the quantum, consumed in the

last cycle(j) of the processes terminated before Pi

𝐶3 = ∑ 𝑄𝑇𝑘,𝑗𝑖−1𝑘=1 (33)

Summing up from category 1 to category 3, these will give us required expression:

𝑃𝑖(𝑇𝐴𝑇) = 𝐶1 + 𝐶2 + 𝐶3

𝑃𝑖(𝑇𝐴𝑇) = ∑ 𝑄𝑇𝑖,𝑘

𝑗

𝑘=1

+ ∑ [∑ 𝑄𝑇𝑙,𝑚 − 𝑄𝑇𝑖,𝑚

𝑛

𝑙=1

]

𝑗−1

𝑚=1

+ ∑ 𝑄𝑇𝑘,𝑗

𝑖−1

𝑘=1

Hence, the following expression is obtained for Pi(TAT)

𝑃𝑖(𝑇𝐴𝑇) = [∑ 𝑄𝑇𝑖,𝑘

𝑗−1

𝑘=1

+ 𝑄𝑇𝑖,𝑗] + ∑ ∑ 𝑄𝑇𝑙,𝑚

𝑛

𝑙=1

− ∑ 𝑄𝑇𝑖,𝑚

𝑗−1

𝑚=1

+

𝑗−1

𝑚=1

∑ 𝑄𝑇𝑘,𝑗

𝑖−1

𝑘=1

− 𝐴𝑇𝑖

= 𝑄𝑇𝑖,𝑗 + ∑ ∑ 𝑄𝑇𝑙,𝑚

𝑛

𝑙=1

+

𝑗−1

𝑚=1

∑ 𝑄𝑇𝑘,𝑗

𝑖−1

𝑘=1

− 𝐴𝑇𝑖

= ∑ ∑ 𝑄𝑇𝑙,𝑚𝑛𝑙=1 +

𝑗−1𝑚=1 ∑ 𝑄𝑇𝑘,𝑗

𝑖𝑘=1 − 𝐴𝑇𝑖 (34)

Average Turnaround Time of a process Pi can be calculated by the following

expression:

Average Turnaround Time= ∑ 𝑃𝑘(𝑇𝐴𝑇)𝑛

𝑘=1

𝑛 (35)

Page 12: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

76 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

2). Formulation of Waiting Time of OMDRRS

Total waiting time for a process 𝑃𝑖 that terminated in jth cycle (Pi(TWT)) can be

calculated by summing up the total time slices devote by the process Pi in the RQ

from first to jth cycle. These time slices may include the following:

1. Number of time slices of full quantum consumed for processes other than Pi,j-

1for the ith process in j-1 cycle [ Pl,m ; l=1(1)n, l≠i and m=1(1) j-1 ]

2. Number of time slices of full or part quantum consumed in the last cycle of the

processes terminated before Pi , j

In the determination of total waiting time for the process Pi, we need to identify the

time slices of each of the above category and compute their number. The expression

to calculate total waiting time of a process is as follows:

Pi(TWT) = CPU time consumed for processes other than Pi – Arrival time of Pi

For category 1: Number of time slices of full quantum consumed for processes other

than Pi,j-1 for the ith process in j-1 cycle [ Pl,m ; l=1(1)n, l≠i and m=1(1) j-1 ]

Time spent of Processes other than Pi in 1st cycle = 𝑄𝑇(𝑙,1)where l=1(1)n, l≠i

Time spent of Processes other than Pi in 2nd cycle = 𝑄𝑇(𝑙,2)where l=1(1)n, l≠i

Hence, in general for cycle j-1, we have

Time spent of Processes other than Pi in (j-1) cycle =𝑄𝑇(𝑙,1) + 𝑄𝑇(𝑙,2) + ……… +

𝑄𝑇𝑙,𝑚 where ; l=1(1)n, l≠i and m=1(1) j-1

𝐶1 = ∑ [ ∑ 𝑄𝑇𝑙,𝑚

𝑛

(𝑙=1,𝑙≠𝑖)

]

𝑗−1

𝑚=1

𝐶1 = ∑ [∑ 𝑄𝑇𝑙,𝑚 − 𝑄𝑇𝑖,𝑚𝑛𝑙=1 ]

𝑗−1𝑚=1 (36)

For category 2: Number of time slices of full or part of the quantum, consumed in the

last cycle(j) of the processes terminated before Pi

𝐶2 = ∑ 𝑄𝑇𝑘,𝑗𝑖−1𝑘=1 (37)

Summing up these will give us required expression:

𝑃𝑖(𝑇𝑊𝑇) = 𝐶1 + 𝐶2

𝑃𝑖(𝑇𝑊𝑇) = ∑ [∑ 𝑄𝑇𝑙,𝑚 − 𝑄𝑇𝑖,𝑚

𝑛

𝑙=1

]

𝑗−1

𝑚=1

+ ∑ 𝑄𝑇𝑘,𝑗

𝑖−1

𝑘=1

Hence, the following expression is obtained for Pi(TWT)

= ∑ [∑ 𝑄𝑇𝑙,𝑚 − 𝑄𝑇𝑖,𝑚𝑛𝑙=1 ]

𝑗−1𝑚=1 + ∑ 𝑄𝑇𝑘,𝑗

𝑖−1𝑘=1 – 𝐴𝑇𝑖 (38)

Page 13: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 77

\

Average Waiting Time of a process Pi may be calculated with the help of following

expression:

Average Waiting Time= ∑ 𝑃𝑘(𝑇𝑊𝑇)𝑛

𝑘=1

𝑛 (39)

IV. SIMULATION AND RESULTS

The simulator OMDRRS was designed and developed using the Microsoft Visual

Basic 6.0 Professional [3]. Several randomly generated data sets were used in an

attempt to compare performance of proposed algorithm OMDRRS with conventional

Round Robin algorithm with respect to average turnaround time, average waiting time

and context switch. For the purpose of assessment of performance of the proposed

algorithm, 50 processes were randomly generated for 10 different problem sizes

ranging from 5 to 50 processes. In all, a total of 500 randomly generated problems

were solved. Results of turnaround time obtained on different data sets are presented

in Figure 1, waiting time obtained on various data sets are presented in Figure 2, and

Figure 3 present the results of context switch based on the 50 processes.

Figure 1:- Turnaround Time of RR Vs. OMDRRS

Figure 2: Waiting Time of RR Vs. OMDRRS

Page 14: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

78 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

Figure 3: Context switch of RR Vs. OMDRRS

The proposed algorithm ‘OMDRRS’ shows better average turnaround time than

Round Robin in all cases. This would, in turn, amount to better results toward average

waiting time also. In terms of context switch OMDRRS serves better than the

conventional Round Robin because of its policy of assigning CPU to the processes

nearing completion. For the visual perception of the difference in performance of

improved dynamic round robin against the conventional round robin we present the

comparative line-graphs for average turnaround time, average waiting time and

context switch in figure 1 to figure 3.

V. CONCLUSION AND FUTURE SCOPE

This paper mathematically analyzes and compares Round Robin scheduling algorithm

with the novel algorithm OMDRRS. The analysis was done to compare the

performance of Round Robin algorithm with respect to dynamic time slice concept in

Round Robin CPU scheduling. The results clearly depicts that OMDRRS performs

better than RR in terms of turnaround time, waiting time & context switch. Results

hence conclude that the proposed algorithm is superior then the commonly used RR

algorithm with less waiting response time, less turnaround time and less number of

context switching; thereby reducing the overheads resulting in saving of lots of

memory space. Taking the base of proposed algorithm further improvement may be

made in future.

REFERENCES

[1] D. Pandey & Vandana; “Improved Round Robin Policy a Mathematical

Approach”, International Journal on Computer Science and Engineering(0975-

3397) Volume 02, No. 04, April 2010

Page 15: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

An Optimal Mathematical Approach for CPU Scheduling – OMDRRS vs. RR 79

\

[2] D Praveen Kumar et. al, “Finding Best Time Quantum for Round Robin

Scheduling Algorithm to avoid Frequent Context Switch”, International Journal

of Computer Science and Information Technologies(0975-9646) Volume 5, No.

5, May 2014

[3] Goel N., Garg R. B., “Performance Analysis of CPU Scheduling Algorithms

with Novel OMDRRS Algorithm”, International Journal of Advanced

Computer Science and Applications”, ISSN : 2158-107X, Volume 7 No.1,

January 2016

[4] A. S. Tanenbaun, Modern Operating Systems, 3rd Edn, Prentice Hall, ISBN:

13: 9780136006633, pp: 1104, 2008.

[5] Rakesh Mohanty, H. S. Behera and et. al, “Design and Performance Evaluation

of a new proposed Shortest Remaining Burst Round Robin(SRBRR) scheduling

algorithm”, Proceedings of the International Symposium on Computer

Engineering and Technology (ISCET), March, 2010.

[6] Behera S. H., Mohanty R., Sahu S. &Bhoi K. S., “Design and Performance

Evaluation of Multi Cyclic Round Robin (MCRR) Algorithm Using Dynamic

Time Quantum”, Journal of Global Research in Computer Science : Volume 2,

No. 2, February 2011, ISSN-2229-371X

[7] Behera S. H., Patel S. & Panda B., “A New Dynamic Round Robin and SRTN

Algorithm with Variable Original Time Slice and Intelligent Time Slice for

Soft Real Time Systems”, International Journal of Computer Applications

(0975 – 8887) Volume 16– No.1, February 2011

[8] Chavan, S., R. & Tikekar, P.,C., “An Improved Optimum Multilevel Dynamic

Round Robin Scheduling Algorithm”, International Journal of Scientific &

Engineering Research, 2013, Vol.4, No.12 , pp. 298-301

[9] S. H. Nazleeni, H. M. A. Anang, M. H. Hasan, A. A. Izzatdin & M. W.

Wirdhayu, “Time comparative simulator for distributed process scheduling

algorithms,” World Academy of Science, Engineering and Technology 19,

pp.84-89,2006

[10] Silberschatz, A. P.B. Galvin and G. Gagne (2012), “Operating System

Concepts”, 8th edition, Wiley India.

[11] Goel N., Garg R. B., “A Simulation of an Optimum Multilevel Dynamic Round

Robin Scheduling Algorithm”, International Journal of Computer Applications ,

ISSN 0975 – 8887, Volume 76– No.7, August 2013

[12] Yadav, R., K., Mishra, A., K., Prakash, N. & Sharma, H. “An improved Round

Robin scheduling algorithm for CPU scheduling”, International Journal on

Computer Science and Engineering, 2010, No.02, pp. 1064-1066.

[13] Matarneh, R., J. Self-Adjustment Time Quantum in Round Robin Algorithm

depending on Burst Time of Running Process. American Journal of Applied

Sciences, 2009, Vol. 10, No.6, pp. 1831-1837.

Page 16: An Optimal Mathematical Approach for CPU Scheduling ...CPU Scheduling Algorithms and an optimal mathematical approach using “Optimum Dynamic Round Robin Scheduling” (OMDRRS) has

80 Neetu Goel, Dr. Abhinav Saxena and Dr. R.B. Garg

[14] Dhakad, V., K. & Sharma L., “Performance analysis of Round Robin

scheduling using adaptive approach based on smart time slice and comparison

with SRR”, International Journal of Advances in Engineering &

Technology(IJAET), May 2012, Vol. 3, No. 2, pp. 333-339.

[15] Goel N. & Garg R. B., “Improvised Optimum Multilevel Dynamic Round

Robin Algorithm for Optimizing CPU Scheduling”, International Journal of

Computer Applications , ISSN 0975 – 8887, Volume – No., August 2015.

[16] Lulla, D., Tayade, J. & Mankar, “Priority based Round Robin CPU Scheduling

using Dynamic Time Quantum”, International Journal on Emerging Trends in

Technology, September 2015, Vol.2, No.2, pp.358-363.

[17] Jain, S., Shukla, D. & Jain, R., “Linear Data Model Based Study of Improved

Round Robin CPU Scheduling algorithm”, International Journal of Advanced

Research in Computer and Communication Engineering, June 2015, Vol.4,

No.6, pp.562-564.

[18] Padhy, C., & Nayak, D. R., “Revamped Round Robin Scheduling Algorithm”,

Journal of Engineering Computers & Applied Sciences (JECAS) Blue Ocean

Research Journals, April 2014, Vol. 3, No. 4, pp. 51-59.

[19] Mostafa, S., M., Rida, S., Z. & Hamad S. H., “Finding time quantum of round

robin CPU scheduling algorithm in general computing systems using integer

programming”, IJRRAS, 2010.

[20] Goel N. & Garg R. B., “A Comparative Study of CPU Scheduling Algorithms”,

International Journal of Graphics Image Processing (IJGIP), Vol 2 issue 4, Dec-

2012

[21] Khankasikam K., “An Adaptive Round Robin Scheduling Algorithm: A

Dynamic Time Quantum Approach”, International Journal of Advancements in

Computing Technology (IJACT), January 2013, Vol. 5, No.1, pp. 595-603.

[22] Li T., Baumberger, D. & Hahn S., “Efficient and Scalable Multiprocessor Fair

Scheduling Using Distributed Weighted Round Robin”, ACM 2009.

[23] Patel J. & Solanki A. K., “Performance Enhancement of CPU Scheduling by

Hybrid Algorithms Using Genetic Approach”, International Journal of

Advanced Research in Computer Engineering & Technology (IJARCET),

June 2012, Vol. 1, No. 4, pp.142-144.

[24] Rao M., V. P. & Shet K. C., “Analysis of New MultiLevel Feedback Queue

Scheduler for Real Time Kernel”, International Journal Of Computational

Cognition, 2010 Yang’s Scientific Research Institute, September 2010, Vol. 8,

No. 3, pp.5-16.

[25] Stallings, W.: “Operating Systems Internals and Design Principles”, 5th edition,

Prentice Hall, (2004).