# Designing of Vague Logic Based 2-Layered Framework for CPU Scheduler

Authors: Supriya Raheja
Journal: Advances in Fuzzy Systems
 (2016)

---

## Abstract

Fuzzy based CPU scheduler has become of great interest by operating system because of its ability to handle imprecise information associated with task. This paper introduces an extension to the fuzzy based round robin scheduler to a Vague Logic Based Round Robin (VBRR) scheduler. VBRR scheduler works on 2-layered framework. At the first layer, scheduler has a vague inference system which has the ability to handle the impreciseness of task using vague logic. At the second layer, Vague Logic Based Round Robin (VBRR) scheduling algorithm works to schedule the tasks. VBRR scheduler has the learning capability based on which scheduler adapts intelligently an optimum length for time quantum. An optimum time quantum reduces the overhead on scheduler by reducing the unnecessary context switches which lead to improve the overall performance of system. The work is simulated using MATLAB and compared with the conventional round robin scheduler and the other two fuzzy based approaches to CPU scheduler. Given simulation analysis and results prove the effectiveness and efficiency of VBRR scheduler.


---

## Body

## 1. Introduction

Multitasking environment of a computer system defines the role of CPU scheduler. The scheduler uses a scheduling algorithm to decide when to schedule the task and for how long. The goal of system designer is to design the CPU scheduler in such a way that it gives users more effective and efficient throughput [1–3]. In this paper, the author discusses the round robin (RR) CPU scheduler.Traditional RR CPU scheduler is not able enough to know the exact attributes of task like burst time, length of time quantum, arrival time, and so forth which affect the performance of system. Recent research works handle the uncertainty of attributes using fuzzy logic [4]. These developments undoubtedly improve the performance of system. The proposed work extends the fuzzy based RR scheduler to vague logic based RR scheduler. The author calls it VBRR CPU scheduler. Vague set theory over fuzzy set theory improves the modelling of real world and becomes a promising tool to handle the impreciseness [5].VBRR scheduler functions are fourfold. First, it addresses the impreciseness and uncertainty using vague logic. Second, it dynamically provides an optimum length of time quantum. Third, it reduces the unnecessary context switches which further reduce the scheduler overhead. Fourth, and the last, it improves the overall performance of system in terms of average response time, average waiting time, average turnaround time, and average normalized turnaround time.VBRR scheduler works on 2-layered framework. First layer is of vague inference system which itself contains four units: Vague Logic Unit, Grade Function Unit, Data Base Unit, andD-Vague Logic Unit. First two functions of VBRR are performed at this layer only. Second layer runs scheduling algorithm to schedule the tasks. The latter two functions are performed at this particular layer.The rest of paper is organized as follows. Section2 outlines the related work with RR scheduler. Section 3 briefly describes the vague set theory and how it is a better tool over fuzzy set theory. Section 4 introduces the 2-layered framework for RR CPU scheduler. Section 5 presents the simulation and results to analyze the performance of VBRR scheduler with the traditional RR scheduler and two other fuzzy based CPU schedulers. Finally, Section 6 concludes the proposed work.


## 2. State of the Art

Round robin (RR) scheduling is specially designed for multitasking systems where users get an impression that multiple tasks are simultaneously running. It is the simplest, fairest, and most widely used scheduling algorithm by CPU scheduler [6]. A fixed size time quantum is assigned to each task in a ready queue and each task is treated equally as shown in Figure 1. Fixed size time quantum is a small portion of CPU time. Round robin scheduling is based on the First Come First Served (FCFS) scheduling. But FCFS scheduling is nonpreemptive type of scheduling whereas round robin is a preemptive scheduling. Therefore, the tasks are interrupted by the system after the completion of assigned time quantum and the system forces the task to temporarily suspend the execution. Later, task resumes its execution when it gets a time quantum.Figure 1
Round robin scheduling.RR scheduling algorithm improves the response time of tasks as compared to other scheduling algorithms. Racu et al. have analyzed the RR scheduling algorithm with respect to response time in 2007. They have derived a best case response time algorithm from the worst case response time algorithm [7].RR scheduling algorithm provides an effective response time but with increased waiting time and turnaround time due to the fixed size time quantum. In 2008, Park et al. gave an approach of quantum based fixed priority scheduling [8]. They combined the concept of quantum with priority of tasks [9] in 2009; they further integrated the concept of preemption threshold with quantum based approach. Every time a task is dispatched to the CPU, a context switch occurs, which adds overhead to the task execution and increases the execution time. However, context switching is an essential feature of any multitasking system; it is the process of loading the states of one task in main memory and storing the states of another task. In RR scheduling, the context switch is the important concern as each task is preempted after the time quantum. It is intensive in computation as well as having the ability to increase the monetary value of the system in terms of processor time. Moreover, it can be costlier operation on an operating system [10]. Hence, there should be a focus on the designing of scheduling algorithm to avoid unnecessary context switches to the possible extent.Number of context switches depends on the size of time quantum used. The smaller size quantum increases the context switches which will degrade the performance of system [6]. Matarneh in 2009 proposed a solution for the fixed size of time quantum. The proposed solution (SARR) adjusts the size of time quantum, based on the CPU burst value of each task [11]. The operating system is not able to adapt this solution immediately as system takes some time to observe the user behaviour, as the needed burst time for user is analyzed initially by operating system. Behera et al. have discussed the problem of high waiting time and turnaround time with RR scheduling algorithm due to the usage of static time quantum [12]. In 2010, they proposed a new version of RR scheduling and had given it the name Dynamic Time Quantum with Readjusted RR (DQRRR) scheduling algorithm. Mostafa et al. have also looked inside the problem of size of time quantum. In the same year, they introduced a method based on integer programming to decide the length of time quantum so that each task gets fair response time and also increases the throughput of the system by reducing unnecessarily context switches [13]. In 2011, Noon et al. provided a solution for fixed time quantum and called this new algorithm AN. The idea of AN algorithm was the same; the operating system itself adjusts the size of time quantum depending on the burst time of all tasks waiting in ready queue [14].Thus, the system designer has an option to decide the size of time quantum by making it not too long and not too short. For example, consider a process whose CPU burst time is 6.2 ms and the fixed time quantum is 2 ms. After execution of 3 cycles, this task will be preempted and assigned to the ready queue. Task needs 0.2 ms more and if before preemption 0.2 ms is given to the process, it will complete its execution. Consequently, its waiting time may be reduced and a chance for another process to be in the queue [15]. The size of time quantum varies with respect to different parameters, namely, burst time, number of tasks present in ready queue, and so forth. These parameters can have imprecise or uncertain values. In order for intellect in a real world where things are not absolutely true, we need a different logic. To keep in line, Professor Zadeh has given fuzzy logic [16] during second half of the last century. Raheja et al. in 2012 have explored the fuzzy approach with RR scheduling. The authors have provided a fuzzy based solution to generate an optimum value for time quantum. The author calls this approach FBRR scheduling algorithm [15]. Alam in 2013 has also explored the option of using fuzzy logic with round robin scheduling algorithm to deal with imprecise values. He designed a Fuzzy Inference System (FIS) that decides the length of time quantum which is optimal for the system, so that each task receives a fair response time and throughput of the system. Otherwise, with fixed time quantum, the throughput of the system decreases due to the unnecessary context switches. The author calls this approach BFRR scheduling algorithm [10].Fuzzy logic uses a concept of single membership value which cannot consider both the evidences of user: evidence in favor and evidence in against. Vague logic effectively handles the impreciseness using both the evidences which fuzzy logic cannot handle [5, 17]. This paper presents a new RR scheduler using the vague set theory. I have called this scheduler “Vague Logic Based Round Robin Scheduler” or VBRR scheduler. VBRR scheduler adapts dynamically the size of time quantum based on the current state of ready queue; thus it is a kind of an intelligent scheduler which further improves the larger waiting time, turnaround time, and normalized turnaround time for tasks. VBRR scheduler also reduces the scheduling overhead by reducing the number of context switches. Finally, this work compares the performance of VBRR with traditional RR, FBRR, and BFRR approaches.


## 3. Vague Set Theory

A number of mathematicians and researchers have been providing a solution to deal with vagueness and impreciseness of knowledge. Professor Zadeh [16] had introduced a novel approach, that is, fuzzy logic. In fuzzy logic, each element has a single grade of membership in interval [
0,1
] [18]. There are a number of generalized forms of fuzzy set theory discussed in the literature by different authors. Atanassov [19] has introduced intuitionistic fuzzy set theory. He extended the fuzzy membership into two functions: membership and nonmembership in the same interval [19, 20]. Pawlak [21] had described another approach to impreciseness called rough set. In this approach, impreciseness is not expressed by single membership but expressed as a pair of sets which provides the lower and upper approximation of the set. Lower and upper approximations give the information about the elements undoubtedly belonging to set and the elements which possibly belong to set, respectively. Professor Gau and Buehrer [5] had introduced another approach over fuzzy set theory and called it vague set theory. They partitions the concept of single membership value μ
F
x into two values: one represents favor value and another represents against value. They pointed out that fuzzy set theory cannot consider both against and favor values individually and even cannot use them at the same time. To differentiate the fuzzy set theory from vague set theory, let us consider X
=
{
x
1
,
x
2
,
…
,
x
n
} is the universe of discourse.Definition 1 (fuzzy set).
A fuzzy setF in X is defined as a pair where x
,
μ
F
x where μ
F
x
→
[
0,1
]. For each object x
∈
F, the value μ
F
(
x
) represents the degree of membership of object x in F as shown in Figure 2. If the value of μ
F
x is more towards 1, the object x belongs more to the set [16].Figure 2
Fuzzy membership function.Definition 2 (vague set).
A vague setV in X is characterized by two membership functions: a truth membership function t
v
:
X
∈
[
0,1
] and a false-membership function f
v
:
X
∈
0,1, where t
v
x is a lower bound of the grade of membership of x derived from the “evidence for x” and f
v
x is a lower bound on the opposition of x derived from the “evidence against x” as shown in Figure 3, and the total of these two independent membership values cannot exceed 1; that is, t
v
x
+
f
v
x
≤
1.Figure 3
Vague membership functions.Definition 3 (vague value).
The grade of membership ofx in the vague set V is bounded by a subinterval t
v
x
,
1
-
f
v
x of [
0,1
], where the interval t
v
x
,
1
-
f
v
x represents the “vague value” of x in V [5].


### 3.1. How Are Both Set Theories Different from Each Other?

LetX be the universe of discourse, say, the collection of burst time of active tasks in operating system. Let V be a vague set of all “high burst time tasks” of the universe X, and let F be a fuzzy set of “high burst time tasks” of X. Suppose an intelligent agent I
1 suggests the membership value μ
F
x for the element x in the fuzzy set F by his expert intellectual potentiality. On the contrary, another intelligent agent I
2 suggests independently two membership values t
v
x and f
v
x for the same element x in the vague set V by his own expert intellectual potentiality. The t
v
x is degree of the true-membership value of x and f
v
x is the false-membership value of x in the vague set V. Both human agents I
1 and I
2 have their limitation of perception, assessment, and working power with real life situations. In the case of fuzzy set F, there is no further check for membership value μ
F
x. In the second case, the agent I
2 suggests independently the membership values t
v
x and f
v
x and makes a further check by keeping the constraint, t
v
x
+
f
v
(
x
)
≤
1. If it is not satisfied, the agent can rethink and reshuffle his assessment.


## 3.1. How Are Both Set Theories Different from Each Other?

LetX be the universe of discourse, say, the collection of burst time of active tasks in operating system. Let V be a vague set of all “high burst time tasks” of the universe X, and let F be a fuzzy set of “high burst time tasks” of X. Suppose an intelligent agent I
1 suggests the membership value μ
F
x for the element x in the fuzzy set F by his expert intellectual potentiality. On the contrary, another intelligent agent I
2 suggests independently two membership values t
v
x and f
v
x for the same element x in the vague set V by his own expert intellectual potentiality. The t
v
x is degree of the true-membership value of x and f
v
x is the false-membership value of x in the vague set V. Both human agents I
1 and I
2 have their limitation of perception, assessment, and working power with real life situations. In the case of fuzzy set F, there is no further check for membership value μ
F
x. In the second case, the agent I
2 suggests independently the membership values t
v
x and f
v
x and makes a further check by keeping the constraint, t
v
x
+
f
v
(
x
)
≤
1. If it is not satisfied, the agent can rethink and reshuffle his assessment.


## 4. VBRR CPU Scheduler

VBRR CPU scheduler works with 2-layered framework as shown in Figure4. At the first layer, scheduler has vague inference system [22–25] which has further four modules. This layer basically handles the impreciseness and uncertainty of active tasks in a system. Moreover, it provides an optimum value for time quantum to the second layer of scheduler where scheduling algorithm works. VBRR scheduling algorithm schedules the tasks for a given time quantum and uses this time quantum to improve the performance of system.Figure 4
2-layered framework for VBRR scheduler.Next sections describe both the layers in detail.


### 4.1. Vague Inference System (VIS)

Our VIS contains four units as shown in Figure5 as follows:(i)
Vague Logic Unit.
(ii)
Grade Function Unit.
(iii)
Data Base Unit.
(iv)
D-Vague Logic Unit.Figure 5
Vague inference system for optimum time quantum.


#### 4.1.1. Vague Logic Unit (VLU)

VLU takes the input burst time (B) from the database and performs the vaguification process [22]. Vaguification process maps the input parameters to the vague value: true-membership (t
Q) and false-membership (f
Q). It considers the present state of ready queue to deal with the uncertainty and impreciseness of tasks. When task arrives in the system, system is not able to exactly know the actual attributes of task; therefore, the VLU considers the maximum B
m
a
x and minimum B
m
i
n values of burst time present in ready queue to handle the exact deviation in current values. Moreover, VLU is also considering the static time quantum (t
S) which is initially assigned by the system. Based on all these values, our Vague Logic Unit computes t
Q using (1) and f
Q using (2):(1)
t
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
a
x
,
(2)
f
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
i
n
.Both t
Q and f
Q must satisfy the following axioms:Axiom 1:t
Q
≤
1.
Axiom 2:f
Q
≤
1.
Axiom 3:t
Q
+
f
Q
≤
1.
Axiom 4:0
≤
t
Q
≤
1
-
f
Q
≤
1.


#### 4.1.2. Grade Function Unit (GFU)

GFU evaluates the degree of accuracy of vague value. The Grade Function is applied to the membership valuest
Q and f
Q which are received from the VLU, as given in(3)
G
Q
=
t
Q
+
f
Q
.Here G
Q represents the grade value. Since, in vague set theory, the sum of these two functions cannot be greater than 1, grade value should also satisfy the following axiom as shown in Figure 6:Axiom 5:G
Q
≤
1.Figure 6
Grade value.


#### 4.1.3. Data Base Unit

It stores all the related information about the tasks like burst time, arrival time, number of currently active tasks, maximum and minimum value of burst time, average burst time, and so forth. All other units extract the current required information from the database.


#### 4.1.4.D-Vague Logic Unit

D-Vague Logic Unit finally maps the grade value to the output value, that is, optimum value of time quantum. The size of time quantum can be calculated using(4)
T
D
=
G
Q
×
N
+
T
s
2
.This dynamic time quantum depends on the grade value, static time quantum, and number of active tasks present in ready queue. It extracts the data from the database. In the next section, the author discusses how the 2nd layer uses this dynamic time quantum.


### 4.2. VBRR Scheduling Algorithm

In our proposed VBRR scheduling algorithm, the tasks are sorted according to their burst time, so that task with shortest burst time will be removed earlier from the ready queue. Optimum time quantum is calculated from the VIS defined in previous section and is used by all active tasks until the complete execution of them. The author discusses the algorithm in Algorithm4 and the respective pseudocode for the algorithm in Pseudocode 1 and Boxes 1, 2, and 3.Pseudocode 1
Begin
Initialize the variables
N = number of ready tasks
T
S  = Static Time Quantum
Do Loop
Initialize the variables
B
N = Burst Time of task
A
N = Arrival Time of task
Until (N
=
=
0
)
Initialize s
u
m
=
0
Do Loop
sum = sum +B
[
N
]
Until (N
=
=
0
)
Calculate B
a
v
g
B
a
v
g = sum/N
for (i
=
1 to N)
B
m
a
x
=
max
⁡
(
B
i
)
⁡
B
m
i
n
=
min
⁡
(
B
i
)
⁡
endfor
Calculate G
Q using true-membership and false-membership function
t
Q = True_membership (B
a
v
g, T
S, B
m
a
x)
f
Q = False_membership (B
a
v
g, B
m
i
n, T
S)
G
Q
=
t
Q
+
f
Q
Calculate T
D
T
D
=
G
Q
×
(
N
+
T
S
)
2
Do Loop
Schedule the task with CPU forT
D time
if a new task has arrived
Recalculate theT
D
else
continue with execution
endif
Until (N
=
=
0
)
Calculate waiting time W
t
i
m
e, response time R
t
i
m
e,  turnaround time T
t
i
m
e and normalized turnaround time N
t
i
m
e.
Avg_Calc( )
EndBox 1
True_membership (B
a
v
g, T
S, B
m
a
x)
Calculate true-membership value t
Q
t
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
a
x
return (t
Q)
endfunctionBox 2
False_membership (B
a
v
g, B
m
i
n, T
S
)
Calculate false-membership value f
Q
f
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
i
n
return (f
Q
)
endfunctionBox 3
Avg_Calc ( )
Calculate average waiting time (AWT)
A
W
T
=
∑
i
=
1
N
W
t
i
m
e
N
Calculate average response time (ART)
A
R
T
=
∑
i
=
1
N
R
t
i
m
e
N
Calculate average turnaround time (ATT)
A
T
T
=
∑
i
=
1
N
T
t
i
m
e
N
Calculate average normalized turnaround time (ANT)
A
N
T
=
∑
i
=
1
N
N
t
i
m
e
N
endfunctionAlgorithm 4.
(
1
) Initialize the variables B
a
v
g, B
m
a
x, and B
m
i
n with the average burst time, maximum burst time, and minimum burst time present in ready queue.
(
2
) Initialize the variables N and T
S.
(
3
) Sort the ready queue in increasing order of burst time.
(
4
) Compute the time quantum T
D from the VIS (Section 4.1).
(
5
) Dispatch and execute the tasks according to the round robin scheduling algorithm using the computed T
D until the ready queue is empty.
(
6
) If a new task arrived, repeat steps from (
1
) to (
5
).
(
7
) Calculate the waiting time, response time, turnaround time, and normalized turnaround time for each task.
(
8
) Finally calculate the average waiting time (AWT), average response time (ART), average turnaround time (ATT), average normalized turnaround time (ATT), and the total context switches (NCS).


## 4.1. Vague Inference System (VIS)

Our VIS contains four units as shown in Figure5 as follows:(i)
Vague Logic Unit.
(ii)
Grade Function Unit.
(iii)
Data Base Unit.
(iv)
D-Vague Logic Unit.Figure 5
Vague inference system for optimum time quantum.


### 4.1.1. Vague Logic Unit (VLU)

VLU takes the input burst time (B) from the database and performs the vaguification process [22]. Vaguification process maps the input parameters to the vague value: true-membership (t
Q) and false-membership (f
Q). It considers the present state of ready queue to deal with the uncertainty and impreciseness of tasks. When task arrives in the system, system is not able to exactly know the actual attributes of task; therefore, the VLU considers the maximum B
m
a
x and minimum B
m
i
n values of burst time present in ready queue to handle the exact deviation in current values. Moreover, VLU is also considering the static time quantum (t
S) which is initially assigned by the system. Based on all these values, our Vague Logic Unit computes t
Q using (1) and f
Q using (2):(1)
t
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
a
x
,
(2)
f
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
i
n
.Both t
Q and f
Q must satisfy the following axioms:Axiom 1:t
Q
≤
1.
Axiom 2:f
Q
≤
1.
Axiom 3:t
Q
+
f
Q
≤
1.
Axiom 4:0
≤
t
Q
≤
1
-
f
Q
≤
1.


### 4.1.2. Grade Function Unit (GFU)

GFU evaluates the degree of accuracy of vague value. The Grade Function is applied to the membership valuest
Q and f
Q which are received from the VLU, as given in(3)
G
Q
=
t
Q
+
f
Q
.Here G
Q represents the grade value. Since, in vague set theory, the sum of these two functions cannot be greater than 1, grade value should also satisfy the following axiom as shown in Figure 6:Axiom 5:G
Q
≤
1.Figure 6
Grade value.


### 4.1.3. Data Base Unit

It stores all the related information about the tasks like burst time, arrival time, number of currently active tasks, maximum and minimum value of burst time, average burst time, and so forth. All other units extract the current required information from the database.


### 4.1.4.D-Vague Logic Unit

D-Vague Logic Unit finally maps the grade value to the output value, that is, optimum value of time quantum. The size of time quantum can be calculated using(4)
T
D
=
G
Q
×
N
+
T
s
2
.This dynamic time quantum depends on the grade value, static time quantum, and number of active tasks present in ready queue. It extracts the data from the database. In the next section, the author discusses how the 2nd layer uses this dynamic time quantum.


## 4.1.1. Vague Logic Unit (VLU)

VLU takes the input burst time (B) from the database and performs the vaguification process [22]. Vaguification process maps the input parameters to the vague value: true-membership (t
Q) and false-membership (f
Q). It considers the present state of ready queue to deal with the uncertainty and impreciseness of tasks. When task arrives in the system, system is not able to exactly know the actual attributes of task; therefore, the VLU considers the maximum B
m
a
x and minimum B
m
i
n values of burst time present in ready queue to handle the exact deviation in current values. Moreover, VLU is also considering the static time quantum (t
S) which is initially assigned by the system. Based on all these values, our Vague Logic Unit computes t
Q using (1) and f
Q using (2):(1)
t
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
a
x
,
(2)
f
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
i
n
.Both t
Q and f
Q must satisfy the following axioms:Axiom 1:t
Q
≤
1.
Axiom 2:f
Q
≤
1.
Axiom 3:t
Q
+
f
Q
≤
1.
Axiom 4:0
≤
t
Q
≤
1
-
f
Q
≤
1.


## 4.1.2. Grade Function Unit (GFU)

GFU evaluates the degree of accuracy of vague value. The Grade Function is applied to the membership valuest
Q and f
Q which are received from the VLU, as given in(3)
G
Q
=
t
Q
+
f
Q
.Here G
Q represents the grade value. Since, in vague set theory, the sum of these two functions cannot be greater than 1, grade value should also satisfy the following axiom as shown in Figure 6:Axiom 5:G
Q
≤
1.Figure 6
Grade value.


## 4.1.3. Data Base Unit

It stores all the related information about the tasks like burst time, arrival time, number of currently active tasks, maximum and minimum value of burst time, average burst time, and so forth. All other units extract the current required information from the database.


## 4.1.4.D-Vague Logic Unit

D-Vague Logic Unit finally maps the grade value to the output value, that is, optimum value of time quantum. The size of time quantum can be calculated using(4)
T
D
=
G
Q
×
N
+
T
s
2
.This dynamic time quantum depends on the grade value, static time quantum, and number of active tasks present in ready queue. It extracts the data from the database. In the next section, the author discusses how the 2nd layer uses this dynamic time quantum.


## 4.2. VBRR Scheduling Algorithm

In our proposed VBRR scheduling algorithm, the tasks are sorted according to their burst time, so that task with shortest burst time will be removed earlier from the ready queue. Optimum time quantum is calculated from the VIS defined in previous section and is used by all active tasks until the complete execution of them. The author discusses the algorithm in Algorithm4 and the respective pseudocode for the algorithm in Pseudocode 1 and Boxes 1, 2, and 3.Pseudocode 1
Begin
Initialize the variables
N = number of ready tasks
T
S  = Static Time Quantum
Do Loop
Initialize the variables
B
N = Burst Time of task
A
N = Arrival Time of task
Until (N
=
=
0
)
Initialize s
u
m
=
0
Do Loop
sum = sum +B
[
N
]
Until (N
=
=
0
)
Calculate B
a
v
g
B
a
v
g = sum/N
for (i
=
1 to N)
B
m
a
x
=
max
⁡
(
B
i
)
⁡
B
m
i
n
=
min
⁡
(
B
i
)
⁡
endfor
Calculate G
Q using true-membership and false-membership function
t
Q = True_membership (B
a
v
g, T
S, B
m
a
x)
f
Q = False_membership (B
a
v
g, B
m
i
n, T
S)
G
Q
=
t
Q
+
f
Q
Calculate T
D
T
D
=
G
Q
×
(
N
+
T
S
)
2
Do Loop
Schedule the task with CPU forT
D time
if a new task has arrived
Recalculate theT
D
else
continue with execution
endif
Until (N
=
=
0
)
Calculate waiting time W
t
i
m
e, response time R
t
i
m
e,  turnaround time T
t
i
m
e and normalized turnaround time N
t
i
m
e.
Avg_Calc( )
EndBox 1
True_membership (B
a
v
g, T
S, B
m
a
x)
Calculate true-membership value t
Q
t
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
a
x
return (t
Q)
endfunctionBox 2
False_membership (B
a
v
g, B
m
i
n, T
S
)
Calculate false-membership value f
Q
f
Q
=
B
a
v
g
B
a
v
g
+
T
S
+
B
m
i
n
return (f
Q
)
endfunctionBox 3
Avg_Calc ( )
Calculate average waiting time (AWT)
A
W
T
=
∑
i
=
1
N
W
t
i
m
e
N
Calculate average response time (ART)
A
R
T
=
∑
i
=
1
N
R
t
i
m
e
N
Calculate average turnaround time (ATT)
A
T
T
=
∑
i
=
1
N
T
t
i
m
e
N
Calculate average normalized turnaround time (ANT)
A
N
T
=
∑
i
=
1
N
N
t
i
m
e
N
endfunctionAlgorithm 4.
(
1
) Initialize the variables B
a
v
g, B
m
a
x, and B
m
i
n with the average burst time, maximum burst time, and minimum burst time present in ready queue.
(
2
) Initialize the variables N and T
S.
(
3
) Sort the ready queue in increasing order of burst time.
(
4
) Compute the time quantum T
D from the VIS (Section 4.1).
(
5
) Dispatch and execute the tasks according to the round robin scheduling algorithm using the computed T
D until the ready queue is empty.
(
6
) If a new task arrived, repeat steps from (
1
) to (
5
).
(
7
) Calculate the waiting time, response time, turnaround time, and normalized turnaround time for each task.
(
8
) Finally calculate the average waiting time (AWT), average response time (ART), average turnaround time (ATT), average normalized turnaround time (ATT), and the total context switches (NCS).


## 5. Simulation and Results

The author has analyzed the performance of proposed work with the RR, FBRR, and BFRR scheduling algorithms. For each comparison, selected sets of tasks were considered and for each case the performance metrics are computed. Results prove that VBRR has better performance as compared to other three algorithms. She presents a Sample Task Set to show the detailed performance analyses of all scheduling algorithms with the help of Gantt chart.


### 5.1. Sample Task Set

Assume a set of five tasks with burst time (T
1
=
20, T
2
=
20, T
3
=
5, T
4
=
3, T
5
=
1). For simplicity, the arrival time of all tasks is considered as 0 ms.


#### 5.1.1. Using RR Scheduling

Assume the static time quantumT
S assigned by system as 2 ms. The scheduling order of tasks using T
S
=
2
m
s is shown in Figure 7(a).Figure 7
(a) Gantt chart using RR approach. (b) Gantt chart using FBRR scheduling algorithm. (c) Gantt chart using BFRR scheduling algorithm.
(a)
(b)
(c)


#### 5.1.2. Using FBRR Scheduling Algorithm

Similarly, the size of time quantum for the Sample Task Set after applying the FBRR scheduling approach isT
Q = 2.6 ms. The scheduling order of tasks with FBRR algorithm is shown in Figure 7(b).


#### 5.1.3. Using BFRR Scheduling Algorithm

After applying BFRR scheduling algorithm, the size of time quantum for the Sample Task Set isT
Q = 2.5 ms. The scheduling order of tasks with BFRR algorithm is shown in Figure 7(c).


#### 5.1.4. Using VBRR Scheduling Algorithm

VBRR algorithm firstly initializes the following variables:(5)
B
m
a
x
=
20
,
B
m
i
n
=
1
,
B
a
v
g
=
9.8
.Then, VIS returns the true- and false-membership functions as given below:(6)
t
Q
=
9.8
31.8
=
0.3
f
Q
=
9.8
12.8
=
0.7
.After that, it computes G
Q as shown in Figure 8 by using t
Q and f
Q:(7)
G
Q
=
t
Q
+
f
Q
=
1
.Then, the time quantum t
D is calculated as(8)
t
D
=
1
∗
5
+
2
2
=
3.5
m
s
.The tasks are scheduled with t
D
=
3.5
m
s. Scheduling order of tasks is shown in Figure 9.Figure 8
Vaguification to degree of accuracy (Sample Task Set).Figure 9
Gantt chart using VBRR scheduling algorithm.


### 5.2. Performance Metrics

To evaluate the performance of VBRR scheduler, the author has chosen all the major performance metrics as discussed below.Definition 5 (average waiting time).
Waiting time is the total time a task waits in ready queue for its turn of execution. Let us consider the time, when task has arrived in the system as arrival time and when task has got the CPU as start time. Waiting time can be calculated as(9)
W
t
i
m
e
=
start  time
-
arrival  time
.For RR scheduling, the task has preempted and resumed the execution multiple times until the task has completed its execution. Then, for further turns, start time acts as next starting time and arrival time as the last time when the task has been executed. The total waiting time is calculated by adding all the waiting times of a task using (9):(10)
W
t
i
m
e
=
start  time
-
arrival  time
+
start  time
-
last  execution  time
+
⋯
.Average waiting time is calculated as the waiting time of all the active tasks in ready queue using (10). It is calculated as(11)
A
W
T
=
∑
i
=
1
N
W
t
i
m
e
N
.Here, N is the number of active tasks. The performance of CPU scheduler depends on the average waiting time. The reduction in AWT is considered as performance improvement of scheduler.Definition 6 (average response time).
Response time is the first start time of task from its arrival to the system. It represents the time when first time task has got the CPU. It is calculated as(12)
R
t
i
m
e
=
start  time
-
arrival  time
.For the nonpreemptive scheduling algorithms, both the waiting time and response time return the same results. Average response time is calculated as the response time of all the active tasks using (12). It is calculated as(13)
A
R
T
=
∑
i
=
1
N
R
t
i
m
e
N
.Definition 7 (average turnaround time).
Turnaround time is the total life time of a task which means the total time a task takes to finish its execution. It can be calculated as(14)
T
t
i
m
e
=
burst  time
+
waiting  time
.Here, burst time represents the time task needs CPU and waiting time is calculated using (9).
Average turnaround time is calculated as the turnaround time of all the active tasks in ready queue using (14). It is calculated as(15)
A
T
T
=
∑
i
=
1
N
T
t
i
m
e
N
.Definition 8 (average normalized turnaround time).
Normalized turnaround time represents the relative delay of a task. It is simply a ratio of turnaround time to burst time. It is calculated as(16)
N
t
i
m
e
=
T
t
i
m
e
burst  time
.Average normalized turnaround time is calculated as the normalized turnaround time of all the active tasks in ready queue using (16). It is calculated as(17)
A
N
T
=
∑
i
=
1
N
N
t
i
m
e
N
.Definition 9 (context switch).
Context switch is a mechanism that is followed by the CPU to switch from one task to another task in a multitasking system. It saves and loads the computer registers. It allows multiple tasks to run; basically it shares a CPU among multiple tasks. Context switching is computationally intensive and does not perform any useful task, so the focus of designers is to optimize the number of context switches.From the Gantt charts shown in Figures7 and 9, the performance metrics of each scheduling algorithms are calculated using (11), (13), (15), and (17).All the graphs for Sample Task Set shown in Figure10 illustrate the reduction in the values of performance metrics from the RR to VBRR scheduling. In Figure 10(f), on the x axis of graph, “1” represents RR scheduler, “2” represents BFRR scheduler, “3” represents FBRR scheduler, and “4” represents VBRR scheduler. From the graph, we can compare the performance of these four algorithms. There is a reduction in performance values at “4” which proves the improvement in performance of VBRR as compared to other three algorithms. Hence, VBRR scheduler has better performance.Figure 10
(a) Waiting time (Sample Task Set). (b) Turnaround time (Sample Task Set). (c) Response time (Sample Task Set). (d) Normalized turnaround time (Sample Task Set). (e) Context switches (Sample Task Set). (f) Overall performance (Sample Task Set).
(a)
(b)
(c)
(d)
(e)
(f)This paper considers multiple task sets to better evaluate the performance of VBRR scheduler over other three approaches. In this work, the author is illustrating the performance with the help of results of 15 task sets.Figures11, 12, 13, 14, and 15 show average waiting time, average response time, average turnaround time, average normalized turnaround time, and number of context switches, respectively. VBRR algorihm is having lowest values in case of all performance metrices. From these graphs, we can conclude that the VBRR algorithm has better performance over the other three algorithms: RR, FBRR, and BFRR algorithms.Figure 11
Average waiting time.Figure 12
Average response time.Figure 13
Average turnaround time.Figure 14
Average normalized turnaround time.Figure 15
Number of context switches.VBRR scheduler improves the performance of CPU scheduler mainly by three reasons. Firstly, it deals with the associated impreciseness and uncertainity with task. Secondly, it provides a dynamic environment of execution for tasks by assigning a dynamic time quantum. Thirdly, it improves the performance of system by reducing the average waiting time, average turnaround time, average normalized turn aroound time, and number of context switches.


## 5.1. Sample Task Set

Assume a set of five tasks with burst time (T
1
=
20, T
2
=
20, T
3
=
5, T
4
=
3, T
5
=
1). For simplicity, the arrival time of all tasks is considered as 0 ms.


### 5.1.1. Using RR Scheduling

Assume the static time quantumT
S assigned by system as 2 ms. The scheduling order of tasks using T
S
=
2
m
s is shown in Figure 7(a).Figure 7
(a) Gantt chart using RR approach. (b) Gantt chart using FBRR scheduling algorithm. (c) Gantt chart using BFRR scheduling algorithm.
(a)
(b)
(c)


### 5.1.2. Using FBRR Scheduling Algorithm

Similarly, the size of time quantum for the Sample Task Set after applying the FBRR scheduling approach isT
Q = 2.6 ms. The scheduling order of tasks with FBRR algorithm is shown in Figure 7(b).


### 5.1.3. Using BFRR Scheduling Algorithm

After applying BFRR scheduling algorithm, the size of time quantum for the Sample Task Set isT
Q = 2.5 ms. The scheduling order of tasks with BFRR algorithm is shown in Figure 7(c).


### 5.1.4. Using VBRR Scheduling Algorithm

VBRR algorithm firstly initializes the following variables:(5)
B
m
a
x
=
20
,
B
m
i
n
=
1
,
B
a
v
g
=
9.8
.Then, VIS returns the true- and false-membership functions as given below:(6)
t
Q
=
9.8
31.8
=
0.3
f
Q
=
9.8
12.8
=
0.7
.After that, it computes G
Q as shown in Figure 8 by using t
Q and f
Q:(7)
G
Q
=
t
Q
+
f
Q
=
1
.Then, the time quantum t
D is calculated as(8)
t
D
=
1
∗
5
+
2
2
=
3.5
m
s
.The tasks are scheduled with t
D
=
3.5
m
s. Scheduling order of tasks is shown in Figure 9.Figure 8
Vaguification to degree of accuracy (Sample Task Set).Figure 9
Gantt chart using VBRR scheduling algorithm.


## 5.1.1. Using RR Scheduling

Assume the static time quantumT
S assigned by system as 2 ms. The scheduling order of tasks using T
S
=
2
m
s is shown in Figure 7(a).Figure 7
(a) Gantt chart using RR approach. (b) Gantt chart using FBRR scheduling algorithm. (c) Gantt chart using BFRR scheduling algorithm.
(a)
(b)
(c)


## 5.1.2. Using FBRR Scheduling Algorithm

Similarly, the size of time quantum for the Sample Task Set after applying the FBRR scheduling approach isT
Q = 2.6 ms. The scheduling order of tasks with FBRR algorithm is shown in Figure 7(b).


## 5.1.3. Using BFRR Scheduling Algorithm

After applying BFRR scheduling algorithm, the size of time quantum for the Sample Task Set isT
Q = 2.5 ms. The scheduling order of tasks with BFRR algorithm is shown in Figure 7(c).


## 5.1.4. Using VBRR Scheduling Algorithm

VBRR algorithm firstly initializes the following variables:(5)
B
m
a
x
=
20
,
B
m
i
n
=
1
,
B
a
v
g
=
9.8
.Then, VIS returns the true- and false-membership functions as given below:(6)
t
Q
=
9.8
31.8
=
0.3
f
Q
=
9.8
12.8
=
0.7
.After that, it computes G
Q as shown in Figure 8 by using t
Q and f
Q:(7)
G
Q
=
t
Q
+
f
Q
=
1
.Then, the time quantum t
D is calculated as(8)
t
D
=
1
∗
5
+
2
2
=
3.5
m
s
.The tasks are scheduled with t
D
=
3.5
m
s. Scheduling order of tasks is shown in Figure 9.Figure 8
Vaguification to degree of accuracy (Sample Task Set).Figure 9
Gantt chart using VBRR scheduling algorithm.


## 5.2. Performance Metrics

To evaluate the performance of VBRR scheduler, the author has chosen all the major performance metrics as discussed below.Definition 5 (average waiting time).
Waiting time is the total time a task waits in ready queue for its turn of execution. Let us consider the time, when task has arrived in the system as arrival time and when task has got the CPU as start time. Waiting time can be calculated as(9)
W
t
i
m
e
=
start  time
-
arrival  time
.For RR scheduling, the task has preempted and resumed the execution multiple times until the task has completed its execution. Then, for further turns, start time acts as next starting time and arrival time as the last time when the task has been executed. The total waiting time is calculated by adding all the waiting times of a task using (9):(10)
W
t
i
m
e
=
start  time
-
arrival  time
+
start  time
-
last  execution  time
+
⋯
.Average waiting time is calculated as the waiting time of all the active tasks in ready queue using (10). It is calculated as(11)
A
W
T
=
∑
i
=
1
N
W
t
i
m
e
N
.Here, N is the number of active tasks. The performance of CPU scheduler depends on the average waiting time. The reduction in AWT is considered as performance improvement of scheduler.Definition 6 (average response time).
Response time is the first start time of task from its arrival to the system. It represents the time when first time task has got the CPU. It is calculated as(12)
R
t
i
m
e
=
start  time
-
arrival  time
.For the nonpreemptive scheduling algorithms, both the waiting time and response time return the same results. Average response time is calculated as the response time of all the active tasks using (12). It is calculated as(13)
A
R
T
=
∑
i
=
1
N
R
t
i
m
e
N
.Definition 7 (average turnaround time).
Turnaround time is the total life time of a task which means the total time a task takes to finish its execution. It can be calculated as(14)
T
t
i
m
e
=
burst  time
+
waiting  time
.Here, burst time represents the time task needs CPU and waiting time is calculated using (9).
Average turnaround time is calculated as the turnaround time of all the active tasks in ready queue using (14). It is calculated as(15)
A
T
T
=
∑
i
=
1
N
T
t
i
m
e
N
.Definition 8 (average normalized turnaround time).
Normalized turnaround time represents the relative delay of a task. It is simply a ratio of turnaround time to burst time. It is calculated as(16)
N
t
i
m
e
=
T
t
i
m
e
burst  time
.Average normalized turnaround time is calculated as the normalized turnaround time of all the active tasks in ready queue using (16). It is calculated as(17)
A
N
T
=
∑
i
=
1
N
N
t
i
m
e
N
.Definition 9 (context switch).
Context switch is a mechanism that is followed by the CPU to switch from one task to another task in a multitasking system. It saves and loads the computer registers. It allows multiple tasks to run; basically it shares a CPU among multiple tasks. Context switching is computationally intensive and does not perform any useful task, so the focus of designers is to optimize the number of context switches.From the Gantt charts shown in Figures7 and 9, the performance metrics of each scheduling algorithms are calculated using (11), (13), (15), and (17).All the graphs for Sample Task Set shown in Figure10 illustrate the reduction in the values of performance metrics from the RR to VBRR scheduling. In Figure 10(f), on the x axis of graph, “1” represents RR scheduler, “2” represents BFRR scheduler, “3” represents FBRR scheduler, and “4” represents VBRR scheduler. From the graph, we can compare the performance of these four algorithms. There is a reduction in performance values at “4” which proves the improvement in performance of VBRR as compared to other three algorithms. Hence, VBRR scheduler has better performance.Figure 10
(a) Waiting time (Sample Task Set). (b) Turnaround time (Sample Task Set). (c) Response time (Sample Task Set). (d) Normalized turnaround time (Sample Task Set). (e) Context switches (Sample Task Set). (f) Overall performance (Sample Task Set).
(a)
(b)
(c)
(d)
(e)
(f)This paper considers multiple task sets to better evaluate the performance of VBRR scheduler over other three approaches. In this work, the author is illustrating the performance with the help of results of 15 task sets.Figures11, 12, 13, 14, and 15 show average waiting time, average response time, average turnaround time, average normalized turnaround time, and number of context switches, respectively. VBRR algorihm is having lowest values in case of all performance metrices. From these graphs, we can conclude that the VBRR algorithm has better performance over the other three algorithms: RR, FBRR, and BFRR algorithms.Figure 11
Average waiting time.Figure 12
Average response time.Figure 13
Average turnaround time.Figure 14
Average normalized turnaround time.Figure 15
Number of context switches.VBRR scheduler improves the performance of CPU scheduler mainly by three reasons. Firstly, it deals with the associated impreciseness and uncertainity with task. Secondly, it provides a dynamic environment of execution for tasks by assigning a dynamic time quantum. Thirdly, it improves the performance of system by reducing the average waiting time, average turnaround time, average normalized turn aroound time, and number of context switches.


## 6. Conclusion

As discussed above, round robin scheduling algorithm improves the response time of the tasks, but with increased waiting time and turnaround time. Moreover, the size of time quantum plays the key role in the performance of RR algorithm. Smaller size can increase the number of context switches that makes the performance of scheduler even worse. There must be a technique inside CPU scheduler, which allows it to dynamically calculate the size of time quantum rather than a fixed size time quantum. This work provides a solution to all the above issues with RR scheduling. The author has introduced a Vague Logic Based Round Robin CPU scheduler. At first layer of VBRR, a vague inference system is designed which dealt with the imprecise parameters of task like burst time, static time quantum by considering the current state of active tasks. Based on the current situation, this vague inference system finally generated an optimum value for time quantum which makes the scheduler work in a dynamic environment. At the second layer, a Vague Logic Based Round Robin scheduling algorithm is introduced to schedule the tasks. The author has evaluated the performance of VBRR algorithm over multiple task sets and compared the performance with RR, BFRR, and FBRR scheduling algorithms. Simulation results illustrate that the VBRR scheduler improves the performance in terms of average waiting time, average turnaround time, and average normalized turnaround time by maintaining the average response time. It consequently improves the performance of the system by reducing the number of context switches.



---

*Source: 2784067-2016-04-13.xml*