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

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


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][2][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, and -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.Section 2 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.

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

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   () 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  = { 1 ,  2 , . . .,   } is the universe of discourse.Definition 1 (fuzzy set).A fuzzy set  in  is defined as a pair where {,   ()} where   () → [0, 1].For each object  ∈ , the value   () represents the degree of membership of object  in  as shown in Figure 2. If the value of   () is more towards 1, the object  belongs more to the set [16].Definition 2 (vague set).A vague set  in  is characterized by two membership functions: a truth membership function  V :  ∈ [0,1] and 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 " as shown in Figure 3, and the total of these two independent membership values cannot exceed 1; that is,  V () +  V () ≤ 1.

How Are Both Set Theories Different from Each
Other?Let  be the universe of discourse, say, the collection of burst   time of active tasks in operating system.Let  be a vague set of all "high burst time tasks" of the universe , and let  be a fuzzy set of "high burst time tasks" of .Suppose an intelligent agent 1 suggests the membership value   () for the element  in the fuzzy set  by his expert intellectual potentiality.On the contrary, another intelligent agent 2 suggests independently two membership values  V () and  V () for the same element  in the vague set  by his own expert intellectual potentiality.The  V () is degree of the truemembership 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, and working power 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 () and makes a further check by keeping the constraint,  V () +  V () ≤ 1.If it is not satisfied, the agent can rethink and reshuffle his assessment.

VBRR CPU Scheduler
VBRR CPU scheduler works with 2-layered framework as shown in Figure 4.At the first layer, scheduler has vague inference system [22][23][24][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.
Next sections describe both the layers in detail.

Vague Inference System (VIS).
Our VIS contains four units as shown in Figure 5 as follows: (i) Vague Logic Unit.
(iii) Data Base Unit.

Vague Logic Unit (VLU)
. VLU takes the input burst time () from the database and performs the vaguification process [22].Vaguification process maps the input parameters to the vague value: true-membership (  ) and false-membership (  ).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  max and minimum  min 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 (  ) which is initially assigned by the system.Based on all these values, our Vague Logic Unit computes   using (1) and   using (2): Both   and   must satisfy the following axioms: Axiom 2:   ≤ 1.

Grade Function Unit (GFU)
. GFU evaluates the degree of accuracy of vague value.The Grade Function is applied to the membership values   and   which are received from the VLU, as given in Here   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:   ≤ 1.

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.

𝐷-Vague
Logic Unit.-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 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.

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 Algorithm 4 and the respective pseudocode for the algorithm in Pseudocode 1 and Boxes 1, 2, and 3. (2) Initialize the variables  and   .
(3) Sort the ready queue in increasing order of burst time.
(4) Compute the time quantum   from the VIS (Section 4.1).
(5) Dispatch and execute the tasks according to the round robin scheduling algorithm using the computed   until the ready queue is empty.(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).

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.

Using RR Scheduling. Assume the static time quantum
assigned by system as 2 ms.The scheduling order of tasks using   = 2 ms is shown in Figure 7(a).

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

Using BFRR Scheduling Algorithm.
After applying BFRR scheduling algorithm, the size of time quantum for the Sample Task Set is TQ = 2.5 ms.The scheduling order of tasks with BFRR algorithm is shown in Figure 7(c).
After that, it computes   as shown in Figure 8 by using   and   : Then, the time quantum   is calculated as The tasks are scheduled with   = 3.5 ms.Scheduling order of tasks is shown in Figure 9.

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 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): Average waiting time is calculated as the waiting time of all the active tasks in ready queue using (10).It is calculated as Here,  is the number of active tasks.The performance of CPU scheduler depends on the average waiting time.The 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 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  time = burst time + waiting time.( 14) Vaguification Degree of accuracy 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 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 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 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.
All the graphs for Sample Task Set shown in Figure 10 illustrate the reduction in the values of performance metrics from the RR to VBRR scheduling.In Figure 10(f), on the  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.
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.Figures 11,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.
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

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.

Figure 5 :
Figure 5: Vague inference system for optimum time quantum.

( 5 )
Then, VIS returns the true-and false-membership functions as given below:
Grade value.Calculate waiting time  time , response time  time , turnaround time  time and normalized turnaround time  time .Algorithm 4. (1) Initialize the variables  avg ,  max , and  min with the average burst time, maximum burst time, and minimum burst time present in ready queue.