# Designing of 2-Stage CPU Scheduler Using Vague Logic

Authors: Supriya Raheja; Reena Dhadich; Smita Rajpal
Journal: Advances in Fuzzy Systems
 (2014)

---

## Abstract

In operating system the CPU scheduler is designed in such a way that all the resources are fully utilized. With static priority scheduling the scheduler ensures that CPU time will be assigned according to the highest priority but ignores other factors; hence it affects the performance. To improve the performance, we propose a new 2-stage vague logic based scheduler. In first stage, scheduler handles the uncertainty of tasks using the proposed vague inference system (VIS). In second stage, scheduler uses a vague oriented priority scheduling (VOPS) algorithm for selection of next process. The goal of this work is to handle the uncertainty as well as to optimize both the average and the amount of variation with respect to performance matrices average waiting time, average turnaround time, and average normalized turnaround time. A simulation using MATLAB is also conducted to evaluate the performance. Simulation results show that the proposed scheduler using VOPS algorithm is better than the scheduler with traditional priority scheduling algorithm. Results are based on the dual concept of fuzzy theory and its generalization, vague theory. Additionally, this work comprises the evaluation of VOPS and shortest job first algorithm. The outcome of proposed VOPS algorithm is much closer to the result obtained by traditional shortest job first.


---

## Body

## 1. Introduction

CPU Scheduler is the main module of any operating system, as it selects the next task to be run. It runs a scheduling algorithm for selection of task. When more than one task is ready to execute, scheduling algorithms will decide which one is to run first. Hence, the designer of scheduler must consider the scheduling algorithm which provides effective throughput.Operating system is not capable to know the exact attributes values of the task, namely, execution time and so forth. Recent developments in priority scheduling have made significantly enhancements to the models considering uncertainty factors. These models accommodate the attributes of tasks with Fuzzy logic.This paper is written with the aim of focusing on the uncertainty and impreciseness of attributes with vague logic and generalized form of fuzzy logic. The vague set theory improves the modeling of real world, becoming a committing tool to deal with imprecise knowledge. In addition to vague implementation, second aim is to improve the performance of priority scheduling algorithm. In this paper we are proposing a new 2-stage scheduler with VOPS (vague oriented priority scheduling) algorithm. Proposed CPU Scheduler works in two stages; for the first stage we are introducing a vague inference system to generate dynamic priorities for tasks by considering the impreciseness of attributes and for second stage of scheduler we are projecting a new vague oriented priority scheduling algorithm to schedule the next process to CPU.The paper is organized as follows. Section2 outlines the related work to the priority scheduling. Section 3 considers the necessary characteristics of vague set theory and the relationship between vague member function. Section 4 includes the proposed scheduler. In Section 5, VOPS is compared with the other algorithms. Finally, Section 6 summarizes the conclusion.


## 2. Related Work

Priority scheduling algorithm is used by scheduler when all tasks are not equally important [1]. In the traditional priority scheduling algorithm, a fixed priority is assigned to each task by system. We call it as a static priority since it is assigned at once and does not change. At each scheduling event, the ready queue is sorted according to priority. It prescribes an environment in which the highest priority is scheduled to the CPU for execution. Tasks of equal priority are scheduled as first come first serve (FCFS). When the task with higher priority comes, the scheduled task is preempted and the new arrive task is scheduled to the CPU [2, 3]. The concept of static priority comprises uncertainty and impreciseness as it does not consider the current state of tasks in the ready queue.To consider the current state of the ready queue, the dynamic priority concept over static priority has introduced that proved the better performance [4, 5]. Dynamic priority means the priority of the tasks varies based on different factors, namely, CPU burst time, waiting time, and response ratio at different levels. So far, the parameters used are crisp. These algorithms did not consider uncertainties and impreciseness, like the number of tasks in the ready queue, task with highest priority having maximum burst time which can starve the tasks with lower burst time, and so forth.Fuzzy logic was introduced by Professor Zadeh in his seminal paper and provides the basis for further development [6, 7]. This imprecise information can be encountered in the scheduling algorithms. To handle the impreciseness or uncertainty in scheduling algorithms fuzzy based priority scheduling algorithms has been proposed [8, 9]. These algorithms have used the concept of fuzzy logic to solve the shortcoming of traditional Priority scheduling algorithm. Undoubtedly, the fuzzy based priority scheduling algorithms improves the performance of static priority scheduling algorithm [9]. Our present work is based on vague set theory which is the further generalization of fuzzy set theory. It is undoubtedly true that the dynamic priority with vague set theory based scheduling is more complicated than the static priority scheduling, although the difference is not as much as it appears.The important aspect of this paper is to generate dynamic priorities for the tasks as it is necessary for the system to consider all the attributes to facilitate dynamic priority. Here system considers two attributes: burst time of the tasks and the static priority. For this we are proposing a 2-stage scheduler using “vague oriented priority scheduling (VOPS) algorithm.” We claim that the proposed algorithm improves the average waiting time, average turnaround time, and average normalized turnaround time.In next section we will discuss preliminaries of vague set theory which is essential to define the proposed work.


## 3. Vague Set Theory

Professor Zadeh had changed the approach in the field of logics by proposing a novel fuzzy logic in 1965 where each element in fuzzy set has a single membership value in between 0 and 1 [6].Definition 1 (fuzzy set).
LetX
=
{
x
1
,
x
2
…
x
n
} be the universe of discourse. A fuzzy set A in X is defined as the set of ordered pairs A
=
{
x
,
μ
A
(
x
)
:
x
∈
X
}, where μ
A
(
x
) is the grade of membership of element x in the set A  [6, 10, 11]. The greater μ
A
(
x
), the greater “element x belongs to the set A.”
Gau and Buehrer [12] had pointed this single membership value μ
A
(
x
) as it combines the evidences for both favor and against value of x. Fuzzy set theory cannot address the two evidences individually, even cannot address the two evidences at the same duration. Gau and Buehrer had introduced the concept of vague set theory [12] over fuzzy set theory.Definition 2 (vague set).
A vague setV in the universe of discourse X is characterized by two membership functions:(1)
a truth membership functiont
v
:
X
∈
[
0,1
],
(2)
a false membership functionf
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” [12]. The total value of these two independent functions cannot exceed 1, that is, t
v
(
x
)
+
f
v
(
x
)
≤
1. The grade of membership of x in the vague set V is bounded by a subinterval [
t
v
(
x
)
,
1
-
f
v
(
x
)
] of [
0,1
].Definition 3 (vague value).
The vague setV is written as V
=
〈
x
,
[
t
v
(
x
)
,
f
v
(
x
)
]
〉
:
x
∈
X, where the interval [
t
v
(
x
)
,
1
-
f
v
(
x
)
] is called the “vague value” of x in V [12].For example, consider a universeX for burst time of the tasks. If the vague value for the burst time of a task is [
0.7,0.8
], means support value (
t
v
) is 0.7, against value (
f
v
) is 0.2 and 0.1 comes under the hesitated value means not in support and not in the against as shown in Figure 1.Figure 1
Vague membership function.Definition 4 (median membership function).
Median membership represents the overall evidence contained in a vague value. It is defined asM
M
=
(
t
v
+
1
-
f
v
)
/
2 having constraint 0
≤
(
t
v
+
1
-
f
v
)
/
2 ≤ 1 as shown in Figure 2.Figure 2
Median membership function.The vague value[
1,1
] has the highest M
M, which means the corresponding element wholly belongs to the vague set. While the vague value [
0,0
] has the lowest M
M means that the corresponding element does not belong to the vague set [13–16].


### 3.1. How Vague Logic Is Different from Fuzzy Logic?

LetX be a universe of discourse; say the collection of burst time of tasks in the ready queue of the operating system. Let V be a vague set of all “high burst time task” of the universe X, and let F be a fuzzy set of all “high burst time task” 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 knowledge. On the adverse, 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 knowledge. 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, working ability 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
), but makes a further check by keeping the constraint, t
v
(
x
)
+
f
v
(
x
)
≤
1. If it is not satisfied, the agent can change his assessment [16].


## 3.1. How Vague Logic Is Different from Fuzzy Logic?

LetX be a universe of discourse; say the collection of burst time of tasks in the ready queue of the operating system. Let V be a vague set of all “high burst time task” of the universe X, and let F be a fuzzy set of all “high burst time task” 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 knowledge. On the adverse, 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 knowledge. 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, working ability 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
), but makes a further check by keeping the constraint, t
v
(
x
)
+
f
v
(
x
)
≤
1. If it is not satisfied, the agent can change his assessment [16].


## 4. Vague Logic Based 2-Stage CPU Scheduler

The proposed vague logic based scheduler has the ability of learning and keeping track of tasks. Based on this capability scheduler adjusts their priorities periodically. For example, if a new task T2 with higher static priority and maximum burst time arrives in the RQ and task T1 with slightly lower priority but minimum burst time is already in the RQ. Then the traditional scheduler will schedule the task T2 based on highest priority but our scheduler will recomputed the priority based on the current values of burst time and static priority and schedules accordingly.Proposed scheduler works in two stages as shown in Figure3; in first stage vague Inference system (VIS) calculates the dynamic priority for each task and in second stage VOPS algorithm selects the highest priority task to be executed.Figure 3
2-Stage scheduler.


### 4.1. Vague Inference System (VIS)

Our considerations are limited to a single processor system that supports a fixed number of tasksN. Each of the N tasks requires B burst time (execution time) and system assign P static priority to these tasks. Each task is independent of each other.LetN tasks be {
T
i
∣
i
=
1
,
…
,
N
}, thenB
i = burst time of ith task
B
max
⁡
=
max
⁡
{
B
1
,
B
2
,
…
,
B
N
}
B
min
⁡
=
min
⁡
{
B
1
,
B
2
,
…
,
B
N
}
LikewiseP
i = static priority of ith task
P
max
⁡
=
max
⁡
{
P
1
,
P
2
,
…
,
P
N
}
P
min
⁡
=
min
⁡
{
P
1
,
P
2
,
…
,
P
N
}where B
max
⁡ is the maximum burst time; B
min
⁡ is the minimum burst time; RQ is the ready queue; P
max
⁡ is the maximum priority; P
min
⁡ is the minimum priority available in ready queue.Proposed VIS has two units, vague logic unit (VLU) and the median membership function unit (MFU) as shown in Figure4.Figure 4
Vague inference system.


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

The idea of pairing the membership (true-membership) and nonmembership (false-membership) values in VLU from vague set theory are to represent the imprecise or uncertain information of tasks discussed in Section2. VLU takes the input as crisp data and converts the crisp data into the vague data [
t
v
,
1
-
f
v
],  t
v true-membership function, and f
v false-membership function. These two functions are used to describe the boundaries of membership value. It takes two crisp inputs burst time and static priority as shown in Figure 4. As scheduler tracks the tasks, the unit VLU considers the current state of tasks in RQ like the membership degree with respect to maximum and minimum burst time. True and false membership functions t
B and f
B for burst time are computed using (1) and (2), respectively. Consider
(1)
t
B
=
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
(2)
f
B
=
B
-
B
min
⁡
B
max
⁡
+
1
,
t
B
+
f
B
≤
1
.
By combining the two equations, (1) and (2), into (3), we get the vague data for burst time of task. Consider
(3)
[
t
B
,
1
-
f
B
]
=
[
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
1
-
B
-
B
min
⁡
B
max
⁡
+
1
]
.
Computation for member functions for static priority t
P and f
P is given in (4). Consider
(4)
t
P
=
P
max
⁡
-
P
P
max
⁡
+
1
,
f
P
=
P
-
P
min
⁡
P
max
⁡
,
t
P
+
f
P
≤
1
.
Similarly, by combining (4), we get the vague data for static priority of task as in (5). Consider
(5)
[
t
P
,
1
-
f
p
]
=
[
P
max
⁡
-
P
P
max
⁡
+
1
,
1
-
P
-
P
min
⁡
P
max
⁡
]
.


#### 4.1.2. Median-Membership Function Unit (MFU)

The output from the VLU is passed as the input to the second unit MFU. MFU computes the aggregate truth value enclosed in the vague value by using the median membership function. Equation (6) could be used to calculate M
B for burst time and M
P for static priority. Consider
(6)
M
B
=
1
-
t
B
+
f
B
2
,
M
B
≤
1
,
M
P
=
1
-
t
P
+
f
P
2
,
M
P
≤
1
.Further, these median membership values are used by VIS to assign the dynamic priorityP
D to each task as given in (7). Our VIS has the restriction that each task’s dynamic priority must be less than or equal to 1. Consider
(7)
P
D
=
max
⁡
⁡
(
M
B
,
M
P
)
,
P
D
≤
1
.


### 4.2. Vague Oriented Priority Scheduling Algorithm

In VOPS algorithm, the tasks are sorted in descending order according to their dynamic priority and the highest priority task is scheduled first to the CPU. Whenever a new task arrives, the dynamic priority is recalculated for all the ready tasks and ready queue is updated accordingly. For Example, if there are 3 tasks T1, T2, and T3 in the RQ. Then the dynamic priority of all these tasks will be calculated. Assuming task T2 is having highest priority, and then T2 will be assigned to CPU. Now during the execution of T2, another task T4 has arrived. After the completion of T2, the dynamic priorities for each task will be recalculated and task with highest priority would be scheduled to CPU.


#### 4.2.1. Performance Metrics

Definition 5 (waiting time).
Waiting time is the total time tasks waits in the ready queue for CPU. The average waiting time is calculated as given in (8). Consider
(8)
W
s
=
∑
i
=
1
N
W
i
N
,
where W
i is the waiting time for each task i.Definition 6 (turnaround time).
Turnaround time is the total time between the submission of a task and its complete execution. For better performance, the average turnaround time should be minimized and it can be calculated as in (9). Consider
(9)
T
s
=
∑
i
=
1
N
T
i
N
,
where T
i is the turnaround time for each task i. Equation (9) can be further defined and given in (10). Consider
(10)
T
s
=
(
∑
i
=
1
N
W
i
+
B
i
)
N
.Definition 7 (normalized turnaround time).
Normalized turnaround time is the ratio of turnaround time to burst time. It represents the relative delay of the task and can be calculated as in (11). Consider
(11)
N
T
s
=
∑
i
=
1
N
(
T
i
/
B
i
)
N
.


#### 4.2.2. VOPS Algorithm Sequence

Algorithm1 is illustrated step by step.Algorithm 1
S
t
e
p
1. For process i:= 1
,
…
,
N loop
(i) AssignB:= burst time;
A:= arrival time;
P:= static Priority;
(ii) Compute the dynamic priorityP
D
i using VIS.
End loop
S
t
e
p
2. For process i:= 1
,
…
,
N loop
RQ:= Sort the processes in decreasing order of P
D
i
End loop
S
t
e
p
3. For process i:= 1
,
…
,
N loop
(i) Schedule and dispatch processi  ∈RQ with CPU.
(ii) Calculate waiting time, turnaround time and normalized turnaround time for processi.
(iii) After completion of each processi, check the RQ. If any new process arrives in the
ready queue then go to Step 1.
End loop
S
t
e
p
4. Calculate average waiting time (Ws), average turnaround time (Ts) and average
normalized turnaround time (NTs) using (8), (10) and (11) respectively.


## 4.1. Vague Inference System (VIS)

Our considerations are limited to a single processor system that supports a fixed number of tasksN. Each of the N tasks requires B burst time (execution time) and system assign P static priority to these tasks. Each task is independent of each other.LetN tasks be {
T
i
∣
i
=
1
,
…
,
N
}, thenB
i = burst time of ith task
B
max
⁡
=
max
⁡
{
B
1
,
B
2
,
…
,
B
N
}
B
min
⁡
=
min
⁡
{
B
1
,
B
2
,
…
,
B
N
}
LikewiseP
i = static priority of ith task
P
max
⁡
=
max
⁡
{
P
1
,
P
2
,
…
,
P
N
}
P
min
⁡
=
min
⁡
{
P
1
,
P
2
,
…
,
P
N
}where B
max
⁡ is the maximum burst time; B
min
⁡ is the minimum burst time; RQ is the ready queue; P
max
⁡ is the maximum priority; P
min
⁡ is the minimum priority available in ready queue.Proposed VIS has two units, vague logic unit (VLU) and the median membership function unit (MFU) as shown in Figure4.Figure 4
Vague inference system.


### 4.1.1. Vague Logic Unit (VLU)

The idea of pairing the membership (true-membership) and nonmembership (false-membership) values in VLU from vague set theory are to represent the imprecise or uncertain information of tasks discussed in Section2. VLU takes the input as crisp data and converts the crisp data into the vague data [
t
v
,
1
-
f
v
],  t
v true-membership function, and f
v false-membership function. These two functions are used to describe the boundaries of membership value. It takes two crisp inputs burst time and static priority as shown in Figure 4. As scheduler tracks the tasks, the unit VLU considers the current state of tasks in RQ like the membership degree with respect to maximum and minimum burst time. True and false membership functions t
B and f
B for burst time are computed using (1) and (2), respectively. Consider
(1)
t
B
=
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
(2)
f
B
=
B
-
B
min
⁡
B
max
⁡
+
1
,
t
B
+
f
B
≤
1
.
By combining the two equations, (1) and (2), into (3), we get the vague data for burst time of task. Consider
(3)
[
t
B
,
1
-
f
B
]
=
[
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
1
-
B
-
B
min
⁡
B
max
⁡
+
1
]
.
Computation for member functions for static priority t
P and f
P is given in (4). Consider
(4)
t
P
=
P
max
⁡
-
P
P
max
⁡
+
1
,
f
P
=
P
-
P
min
⁡
P
max
⁡
,
t
P
+
f
P
≤
1
.
Similarly, by combining (4), we get the vague data for static priority of task as in (5). Consider
(5)
[
t
P
,
1
-
f
p
]
=
[
P
max
⁡
-
P
P
max
⁡
+
1
,
1
-
P
-
P
min
⁡
P
max
⁡
]
.


### 4.1.2. Median-Membership Function Unit (MFU)

The output from the VLU is passed as the input to the second unit MFU. MFU computes the aggregate truth value enclosed in the vague value by using the median membership function. Equation (6) could be used to calculate M
B for burst time and M
P for static priority. Consider
(6)
M
B
=
1
-
t
B
+
f
B
2
,
M
B
≤
1
,
M
P
=
1
-
t
P
+
f
P
2
,
M
P
≤
1
.Further, these median membership values are used by VIS to assign the dynamic priorityP
D to each task as given in (7). Our VIS has the restriction that each task’s dynamic priority must be less than or equal to 1. Consider
(7)
P
D
=
max
⁡
⁡
(
M
B
,
M
P
)
,
P
D
≤
1
.


## 4.1.1. Vague Logic Unit (VLU)

The idea of pairing the membership (true-membership) and nonmembership (false-membership) values in VLU from vague set theory are to represent the imprecise or uncertain information of tasks discussed in Section2. VLU takes the input as crisp data and converts the crisp data into the vague data [
t
v
,
1
-
f
v
],  t
v true-membership function, and f
v false-membership function. These two functions are used to describe the boundaries of membership value. It takes two crisp inputs burst time and static priority as shown in Figure 4. As scheduler tracks the tasks, the unit VLU considers the current state of tasks in RQ like the membership degree with respect to maximum and minimum burst time. True and false membership functions t
B and f
B for burst time are computed using (1) and (2), respectively. Consider
(1)
t
B
=
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
(2)
f
B
=
B
-
B
min
⁡
B
max
⁡
+
1
,
t
B
+
f
B
≤
1
.
By combining the two equations, (1) and (2), into (3), we get the vague data for burst time of task. Consider
(3)
[
t
B
,
1
-
f
B
]
=
[
B
max
⁡
-
B
+
1
B
max
⁡
+
1
,
1
-
B
-
B
min
⁡
B
max
⁡
+
1
]
.
Computation for member functions for static priority t
P and f
P is given in (4). Consider
(4)
t
P
=
P
max
⁡
-
P
P
max
⁡
+
1
,
f
P
=
P
-
P
min
⁡
P
max
⁡
,
t
P
+
f
P
≤
1
.
Similarly, by combining (4), we get the vague data for static priority of task as in (5). Consider
(5)
[
t
P
,
1
-
f
p
]
=
[
P
max
⁡
-
P
P
max
⁡
+
1
,
1
-
P
-
P
min
⁡
P
max
⁡
]
.


## 4.1.2. Median-Membership Function Unit (MFU)

The output from the VLU is passed as the input to the second unit MFU. MFU computes the aggregate truth value enclosed in the vague value by using the median membership function. Equation (6) could be used to calculate M
B for burst time and M
P for static priority. Consider
(6)
M
B
=
1
-
t
B
+
f
B
2
,
M
B
≤
1
,
M
P
=
1
-
t
P
+
f
P
2
,
M
P
≤
1
.Further, these median membership values are used by VIS to assign the dynamic priorityP
D to each task as given in (7). Our VIS has the restriction that each task’s dynamic priority must be less than or equal to 1. Consider
(7)
P
D
=
max
⁡
⁡
(
M
B
,
M
P
)
,
P
D
≤
1
.


## 4.2. Vague Oriented Priority Scheduling Algorithm

In VOPS algorithm, the tasks are sorted in descending order according to their dynamic priority and the highest priority task is scheduled first to the CPU. Whenever a new task arrives, the dynamic priority is recalculated for all the ready tasks and ready queue is updated accordingly. For Example, if there are 3 tasks T1, T2, and T3 in the RQ. Then the dynamic priority of all these tasks will be calculated. Assuming task T2 is having highest priority, and then T2 will be assigned to CPU. Now during the execution of T2, another task T4 has arrived. After the completion of T2, the dynamic priorities for each task will be recalculated and task with highest priority would be scheduled to CPU.


### 4.2.1. Performance Metrics

Definition 5 (waiting time).
Waiting time is the total time tasks waits in the ready queue for CPU. The average waiting time is calculated as given in (8). Consider
(8)
W
s
=
∑
i
=
1
N
W
i
N
,
where W
i is the waiting time for each task i.Definition 6 (turnaround time).
Turnaround time is the total time between the submission of a task and its complete execution. For better performance, the average turnaround time should be minimized and it can be calculated as in (9). Consider
(9)
T
s
=
∑
i
=
1
N
T
i
N
,
where T
i is the turnaround time for each task i. Equation (9) can be further defined and given in (10). Consider
(10)
T
s
=
(
∑
i
=
1
N
W
i
+
B
i
)
N
.Definition 7 (normalized turnaround time).
Normalized turnaround time is the ratio of turnaround time to burst time. It represents the relative delay of the task and can be calculated as in (11). Consider
(11)
N
T
s
=
∑
i
=
1
N
(
T
i
/
B
i
)
N
.


### 4.2.2. VOPS Algorithm Sequence

Algorithm1 is illustrated step by step.Algorithm 1
S
t
e
p
1. For process i:= 1
,
…
,
N loop
(i) AssignB:= burst time;
A:= arrival time;
P:= static Priority;
(ii) Compute the dynamic priorityP
D
i using VIS.
End loop
S
t
e
p
2. For process i:= 1
,
…
,
N loop
RQ:= Sort the processes in decreasing order of P
D
i
End loop
S
t
e
p
3. For process i:= 1
,
…
,
N loop
(i) Schedule and dispatch processi  ∈RQ with CPU.
(ii) Calculate waiting time, turnaround time and normalized turnaround time for processi.
(iii) After completion of each processi, check the RQ. If any new process arrives in the
ready queue then go to Step 1.
End loop
S
t
e
p
4. Calculate average waiting time (Ws), average turnaround time (Ts) and average
normalized turnaround time (NTs) using (8), (10) and (11) respectively.


## 4.2.1. Performance Metrics

Definition 5 (waiting time).
Waiting time is the total time tasks waits in the ready queue for CPU. The average waiting time is calculated as given in (8). Consider
(8)
W
s
=
∑
i
=
1
N
W
i
N
,
where W
i is the waiting time for each task i.Definition 6 (turnaround time).
Turnaround time is the total time between the submission of a task and its complete execution. For better performance, the average turnaround time should be minimized and it can be calculated as in (9). Consider
(9)
T
s
=
∑
i
=
1
N
T
i
N
,
where T
i is the turnaround time for each task i. Equation (9) can be further defined and given in (10). Consider
(10)
T
s
=
(
∑
i
=
1
N
W
i
+
B
i
)
N
.Definition 7 (normalized turnaround time).
Normalized turnaround time is the ratio of turnaround time to burst time. It represents the relative delay of the task and can be calculated as in (11). Consider
(11)
N
T
s
=
∑
i
=
1
N
(
T
i
/
B
i
)
N
.


## 4.2.2. VOPS Algorithm Sequence

Algorithm1 is illustrated step by step.Algorithm 1
S
t
e
p
1. For process i:= 1
,
…
,
N loop
(i) AssignB:= burst time;
A:= arrival time;
P:= static Priority;
(ii) Compute the dynamic priorityP
D
i using VIS.
End loop
S
t
e
p
2. For process i:= 1
,
…
,
N loop
RQ:= Sort the processes in decreasing order of P
D
i
End loop
S
t
e
p
3. For process i:= 1
,
…
,
N loop
(i) Schedule and dispatch processi  ∈RQ with CPU.
(ii) Calculate waiting time, turnaround time and normalized turnaround time for processi.
(iii) After completion of each processi, check the RQ. If any new process arrives in the
ready queue then go to Step 1.
End loop
S
t
e
p
4. Calculate average waiting time (Ws), average turnaround time (Ts) and average
normalized turnaround time (NTs) using (8), (10) and (11) respectively.


## 5. Simulation and Results

MATLAB is used to simulate our effort in designing the algorithm. To implement the VIS of the two functions which are defined inside the VLU,burst_time andpriority.Algorithm2 is the snippet for functionburst_time that shows how the burst values are extracting from the RQ.Algorithm 2
b
max
⁡
= max(b);
b
min
⁡= min(b);
fori
=
1 : n
t
B = (
b
max
⁡
-
b
(
i
)
+
1
)
/
(
b
max
⁡
+
1
);
f
B = (
b
(
i
)
-
b
min
⁡
)
/
(
b
max
⁡
+
1);
endAlgorithm3 gives the idea about the generation of dynamic priorities which is further used by scheduler to schedule the task.Algorithm 3
[
y
,
z
] = Priority(P
,
n);
[
a
,
c
] = burst_time(B
,
n);
fori
=
1 : n
M
B(i) = (a
(
i
)
+
1
-
c
(
i
)
)
/
2;
M
P(i) = (y
(
i
)
+
1
-
z
(
i
)
)
/
2;
D
P(i) = max(M
B(i), M
P(i));
EndFor the working of algorithm, consider a simple example involving 5 different tasks T1 to T5. Table1 contains the given burst time and the static priority for these tasks. This simple example shows how the dynamic priorities are calculated using VIS.Table 1
Example Task Set 1.
Task
T1
T2
T3
T4
T5
Priority
6
5
1
4
2
Burst time
3
24
6
9
8The VIS extracts the static priority and burst time for each task T1–T5. After applying thepriority andburst_time functions on this task set, we get the values as given below:
(12)
y
=
t
P
=
0
0.1429
0.7143
0.2857
0.5714
,
z
=
f
P
=
0.8333
0.6667
0
0.5000
0.1667
,
a
=
t
B
=
0.8800
0.0400
0.7600
0.6400
0.6800
,
c
=
f
B
=
0
0.8400
0.1200
0.2400
0.2000
.
After applying (6), the values of M
B and M
P are
(13)
M
B
=
0.9400
0.1000
0.8200
0.7000
0.7400
,
M
P
=
0.0833
0.2381
0.8571
0.3929
0.7024
.
Finally by considering the maximum value between M
B and M
P, we can calculate the value of dynamic priority using (7). Consider
(14)
P
D
=
0.9400
0.2381
0.8571
0.7000
0.7400
.
The updated task set with dynamic priority is given in Table 2.Table 2
Updated Task Set 1.
Task
T1
T2
T3
T4
T5
Dynamic priority
0.94
0.23
0.85
0.7
0.74
Burst time
3
24
6
9
8Now the VOPS algorithm is applied over the updated Task set 1. The highest priority task is scheduled first to the CPU. Scheduling is represented in the form of Gantt chart as given in Figure5(a).(a) Gantt chart for VOPS. (b) Gantt chart for PS. (c) Gantt chart for SJF. (d) Gantt chart for FS.
(a)
(b)
(c)
(d)When we schedule the task set in Table1 using PS, SJF, and FS algorithm, the Gantt chart is shown in Figures 5(b), 5(c), and 5(d), respectively.Based on the Gantt chart waiting time, turnaround time and normalized turnaround time are computed as shown in Figures6(a), 6(b), and 6(c), respectively.(a) Waiting time for sample task set 1. (b) Turnaround time for sample task set 1. (c) Normalized turnaround time for sample task set 1. (d) Results of sample task 1.
(a)
(b)
(c)
(d)Further we have calculated the average waiting time (W
s), average turnaround time (T
s), and average normalized turnaround time using (8), (10), and (11) for each algorithm, respectively. Outcomes of all algorithms are shown in Figure 6(d) and also summarized in Table 3.Table 3
Outcomes of Task Set 1.
S. no.
Scheduling technique
W
s (ns)
T
s (ns)
N
s (ns)
1
PS
22
32
3.99
2
SJF
11
21
1.92
3
FS
12
22
3.99
4
VOPS
11
21
1.92From the outcomes of Task Set 1 given in Table3, one can analyze that the performance of VOPS is better than traditional approach PS and Fuzzy approach FS. Also the results of VOPS algorithm is similar to SJF algorithm which is known as an optimum scheduling algorithm. Now consider the second task set with 4 tasks as given in Table 4.Table 4
Example Task Set 2.
Task
T1
T2
T3
T4
Priority
7
1
15
4
Burst time
10
5
4
8As mentioned in Task Set 1, VIS extracts the priority and burst time of each task and generates the dynamic priority as given in Table5.Table 5
Updated Task Set 2.
Task
T1
T2
T3
T4
Dynamic priority
0.55
0.94
0.82
0.74
Burst time
10
5
4
8Once again after applying VOPS algorithm to the updated Task Set 2 and it is scheduled as shown in Figure7(a).(a) Gantt chart for VOPS. (b) Gantt chart for PS. (c) Gantt chart for SJF. (d) Gantt chart for FS.
(a)
(b)
(c)
(d)Then all of the remaining three algorithms PS, SJF, and FS are applied. Gantt chart for all is shown in Figures7(b), 7(c), and 7(d), respectively.Figures8(a), 8(b), and 8(c) represent the comparison of the waiting time, turnaround time, and the normalized turnaround time of each task.(a) Waiting time for sample task set 2. (b) Turnaround time for sample task set 2. (c) Normalized turnaround time for sample task set 1. (d) Results of sample task 2.
(a)
(b)
(c)
(d)The overall computation of Sample Task Set 2 in terms of average waiting time, average turnaround time, and average normalized turnaround time is shown in Figure8(d).Overall results of each scheduling techniques are analyzed in Table6.Table 6
Outcomes of Task Set 2.
S. no.
Scheduling technique
W
s (ns)
T
s (ns)
N
s (ns)
1
PS
10
16.75
2.64
2
SJF
7.5
14.25
1.91
3
FS
8
14.75
2.02
4
VOPS
7.75
14.5
2.01Similarly, one can judge that the performance of proposed VOPS algorithm, given in Table6, is better than the PS and FS and more close to SJF.VOPS algorithm are simulated on different task sets having the random values of burst time and static priority and the average waiting time, average turnaround time, and average normalized turnaround time for each task set are calculated. For accuracy VOPS algorithm is compared for all task sets with other algorithms such as priority scheduling (PS), shortest job first (SJF), and fuzzy based priority scheduling (FS).Figure9 shows the performance in terms of average waiting time. Figures 10 and 11 show the performance in terms of average turnaround time and average normalized turnaround time. Form the graph we can evaluate the performance of our proposed work. From the graphs we can see that our algorithm results are in between the FS and SJF, better than FS and nearby SJF but in some cases equal to SJF. As we know, SJF is the optimum scheduling algorithm; it clearly signifies the performance of our algorithm. However, we agree there is no so much difference between FS and VOPS, but VOPS is considering the impreciseness in more general way by perceiving the evidence in favour and evidence in against.Figure 9
Average waiting time.Figure 10
Average turnaround time.Figure 11
Average normalized turnaround time.VOPS scheduling algorithm has better performance mainly by two reasons.The proposed VOPS algorithm is considering the current state of tasks in ready queue and address the impreciseness of data. As a result, VOPS is effective for dynamic environment. Secondly, the performance of scheduling algorithms mainly depends on multiple factors, namely, average waiting time, average turnaround time, and average normalized turnaround time. The reduction in the value of factors improves the performance. As a result, VOPS improves the performance of the system.


## 6. Conclusion

As discussed above some applications and research show that SJF algorithm is better than the priority scheduling algorithm since it provides the less waiting time and less turnaround time. In dynamic applications, priority algorithm must be required by scheduler to assign the different priority order to different tasks. In this paper we have introduced a 2-stage CPU scheduler based on vague set theory. In the first stage, scheduler used the VIS to handle the impreciseness and uncertainty. For this purpose, VIS applied the vague set theory and converted crisp data in to vague data. To determine the total evidence in vague values, the median membership function is used in the VIS. Finally VIS generated the dynamic priority for all tasks in ready queue by considering the factors burst time and the user priority. In the second stage, scheduler has selected the next task with vague oriented priority scheduling (VOPS) algorithm. The proposed 2-stage scheduler improves the performance of the system as compared to the system using conventional priority scheduling algorithm and fuzzy scheduling algorithm. To validate the performance we have simulated different task sets which verifies that our propose algorithm significantly reduces the average waiting time, average turnaround time, and average normalized turnaround time and consequently improves the performance.



---

*Source: 841976-2014-07-22.xml*