Designing of 2-Stage CPU Scheduler Using Vague Logic

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 usingVOPS 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.


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.Section 2 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.

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.

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).Let  = { 1 ,  2 . . .  } be the universe of discourse.A fuzzy set  in  is defined as the set of ordered pairs  = {,   () :  ∈ }, where   () is the grade of membership of element  in the set  [6,10,11].The greater   (), the greater "element  belongs to the set . " Gau and Buehrer [12] had pointed this single membership value   () as it combines the evidences for both favor and against value of .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 set  in the universe of discourse  is characterized by two membership functions: (1) a truth membership function  V : ∈ [0, 1], (2) a false membership function  V : ∈ [0, 1], where  V () is a lower bound of the grade of membership of  derived from the "evidence for , " and  V () is a lower bound on the opposition of  derived from the "evidence against " [12].The total value of these two independent functions cannot exceed 1, that is,  V () +  V () ≤ 1.The grade of membership of  in the vague set  is bounded by a subinterval

Definition 3 (vague value). The vague set 𝑉 is written as
For example, consider a universe  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 ( V ) is 0.7, against value ( 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.

Definition 4 (median membership function). Median membership represents the overall evidence contained in a vague value. It is defined as
The vague value [1,1] has the highest   , which means the corresponding element wholly belongs to the vague set.While the vague value [0, 0] has the lowest   means that the corresponding element does not belong to the vague set [13][14][15][16].

How Vague Logic Is Different from Fuzzy
Logic?Let  be a universe of discourse; say the collection of burst time of tasks in the ready queue of the operating system.Let  be a vague set of all "high burst time task" of the universe , and let  be a fuzzy set of all "high burst time task" of .Suppose an intelligent agent  1 suggests the membership value   () for the element  in the fuzzy set  by his expert knowledge.On the adverse, another intelligent agent  2 suggests independently two membership values  V () and  V () for the same element  in the vague set  by his own knowledge.The  V () is degree of the true-membership value of  and  V () is the false-membership value of  in the vague set .Both human agents  1 and  2 have their limitation of perception, assessment, working ability with real life situations.In the case of fuzzy set , there is no further check for membership value   ().In the second case, the agent  2 suggests independently the membership values  V () and  V (), but makes a further check by keeping the constraint,  V () +  V () ≤ 1.If it is not satisfied, the agent can change his assessment [16].

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 Figure 3; 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.

Vague Inference System (VIS).
Our considerations are limited to a single processor system that supports a fixed number of tasks .Each of the  tasks requires  burst time (execution time) and system assign  static priority to these tasks.Each task is independent of each other.
Let  tasks be {  |  = 1, . . ., }, then   = burst time of ith task Proposed VIS has two units, vague logic unit (VLU) and the median membership function unit (MFU) as shown in Figure 4.

Vague Logic Unit (VLU).
The idea of pairing the membership (true-membership) and nonmembership (falsemembership) values in VLU from vague set theory are to represent the imprecise or uncertain information of tasks discussed in Section 2. VLU takes the input as crisp data and converts the crisp data into the vague data [ V , 1− V ],  V truemembership function, and  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   and   for burst time are computed using ( 1) and ( 2), respectively.Consider By combining the two equations, ( 1) and ( 2), into (3), we get the vague data for burst time of task.Consider Computation for member functions for static priority   and   is given in (4).Consider Similarly, by combining (4), we get the vague data for static priority of task as in (5).Consider

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   for burst time and   for static priority.Consider Further, these median membership values are used by VIS to assign the dynamic priority   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   = max (  ,   ) ,   ≤ 1. (7)

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.

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 where   is the waiting time for each task .
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 where   is the turnaround time for each task .Equation ( 9) can be further defined and given in (10).Consider  8), ( 10) and ( 11) respectively.

VOPS Algorithm
Sequence.Algorithm 1 is illustrated step by step.

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 and priority.Algorithm 2 is the snippet for function burst time that shows how the burst values are extracting from the RQ.
Algorithm 3 gives the idea about the generation of dynamic priorities which is further used by scheduler to schedule the task.
For the working of algorithm, consider a simple example involving 5 different tasks T1 to T5.Table 1 contains the given burst time and the static priority for these tasks.This simple example shows how the dynamic priorities are calculated using VIS.The VIS extracts the static priority and burst time for each task T1-T5.After applying the priority and burst time functions on this task set, we get the values as given below:  =   = 0 0.1429 0.7143 0.2857 0.5714,  =   = 0.8333 0.6667 0 0.5000 0.1667,  =   = 0.8800 0.0400 0.7600 0.6400 0.6800,  =   = 0 0.8400 0.1200 0.2400 0.2000.(12) After applying (6), the values of   and   are   = 0.9400 0.1000 0.8200 0.7000 0.7400,   = 0.0833 0.2381 0.8571 0.3929 0.7024. ( Finally by considering the maximum value between   and   , we can calculate the value of dynamic priority using (7).Consider   = 0.9400 0.2381 0.8571 0.7000 0.7400.( The updated task set with dynamic priority is given in Table 2. Now 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 Figure 5(a).When we schedule the task set in Table 1 using PS, SJF, and FS algorithm, the Gantt chart is shown in Figures 5(b Further we have calculated the average waiting time (  ), average turnaround time (  ), 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.
From the outcomes of Task Set 1 given in Table 3, 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.
As mentioned in Task Set 1, VIS extracts the priority and burst time of each task and generates the dynamic priority as given in Table 5.
Once again after applying VOPS algorithm to the updated Task Set 2 and it is scheduled as shown in Figure 7(a).
Then all of the remaining three algorithms PS, SJF, and FS are applied.Gantt chart for all is shown in Figures 7(b 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 Figure 8(d).
Overall results of each scheduling techniques are analyzed in Table 6.
Similarly, one can judge that the performance of proposed VOPS algorithm, given in Table 6, 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).
Figure 9 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.
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.

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 2stage 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.
), 7(c), and 7(d), respectively.Figures 8(a), 8(b), and 8(c) represent the comparison of the waiting time, turnaround time, and the normalized turnaround time of each task.

Figure 6 :Figure 7 :
Figure 6: (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.

Figure 8 :
Figure 8: (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.
) Calculate waiting time, turnaround time and normalized turnaround time for process .(iii) After completion of each process , check the RQ.If any new process arrives in the ready queue then go to Step 1. End loop  4. Calculate average waiting time (Ws), average turnaround time (Ts) and average normalized turnaround time (NTs) using (

Table 3 :
Outcomes of Task Set 1.

Table 6 :
Outcomes of Task Set 2.