Improving Scheduling Criteria of Preemptive Tasks Scheduled under Round Robin Algorithm using Changeable Time Quantum

,


Introduction
When a computer is multi-programmed, it frequently has multiple processes competing for the CPU at the same time. When more than one process is in the ready state and there is only one CPU available, the operating system must decide which process to run first. The part of operating system that makes the choice is called short term scheduler or CPU scheduler. The algorithm that it uses is called scheduling algorithm. There are several scheduling algorithms. Different scheduling algorithms have different properties and the choice of a particular algorithm may favor one class of processes over another. Many criteria have been suggested for comparing CPU scheduling algorithms and deciding which one is the best algorithm [19].
Some of the criteria include (i)Fairness (ii)CPU utilization (iii) Throughput (iv)Turnaround time (v)Waiting time (vi)Response time (vii)Context switches. It is desirable to maximize CPU utilization and throughput, to minimize turnaround time, waiting time, response time and context switches and to avoid starvation of any process [13,20]. Some of the scheduling algorithms are briefly described below: FCFS: In First come First serve scheduling algorithm the process that request first is scheduled for execution [13,19,20]. SJF: In shortest Job first scheduling algorithm the process with the minimum burst time is scheduled for execution [13,20]. SRTN: In shortest Remaining time next scheduling algorithm, the process with shortest remaining time is scheduled for execution [19]. Priority: in Priority Scheduling algorithm the process with highest priority is scheduled for execution [13,19,20]. Multilevel queue scheduling: In this the ready queue is partitioned into several separate queues. The processes are permanently assigned to one queue generally based on some property of the process such as memory size, process priority or process type. Each queue has its own scheduling algorithm. There is scheduling among the queues, which is commonly implemented as fixed-priority preemptive scheduling. Each queue has absolute priority over low priority queues [13]. Multilevel feedbackqueue scheduling: This is like Multilevel queue scheduling but allows a process to move between queues [13]. Fair share Scheduling: Fair share scheduler considers the execution history of a related group of processes, along with the individual execution history of each process in making scheduling decision. The user community is divided into a fair-share groups. Each group is allocated a fraction of CPU time.
Scheduling is done on the basis of priority of the process, its recent processor usage and the recent processor usages of the group to which the process belongs. Each process is assigned a base priority. The priority of a process drops as the process uses the processor and as the group to which process belongs uses the processor [19]. Guaranteed scheduling: In this a ratio of actual CPU time a process had and its entitled CPU time is calculated. The process with this lowest ration is scheduled [20]. Lottery Scheduling: The basic idea is to give processes lottery tickets for CPU time. Whenever a scheduling decision has to be made, a lottery ticket is chosen at random and the process holding the ticket gets the CPU [20]. HRRN: In this, response ratio is calculated for each process. The process with the highest ratio is scheduled for execution [19] Round-robin: In this, the CPU scheduler goes around the ready queue allocating the CPU to each process for a time interval of up to one time quantum. If time quantum is too large, the response time of the processes is too much which may not be tolerated in interactive environment. If time quantum is too small, it causes unnecessarily frequent context switch leading to more overheads resulting in less throughput. In this paper we proposed a new technique depending on making the value of the time quantum changeable, this value is neither too large nor too small such that every process has got reasonable response time and the throughput of the system is not decreased due to unnecessarily context switches.
To this end, we utilize the following assumptions throughout this paper to simplify the problem formulation: • tasks are belong to interactive environment, i.e., tasks are premptive. In an environment with interactive users, preemption is essential to keep one process from hogging the CPU and denying service to the others. Even if no process intentionally ran forever, due to a program bug, one process might shut out all the others indefinitely. Preemption is needed to prevent this behavior, • tasks are of variable size in terms of number of instructions which may range anywhere from instructions up to thousands or greater for some interactive tasks.
• no task is rated more important than any other task, • each task is considered to be independent of all others, i.e., there is no communication be tween tasks running on the processor, • the CPU cost of each task is assumed to be known.
• new tasks are permitted to enter the queue.
From these assumptions, it is clear that the problem has been reduced to almost the simplest formulation. The most common method of task scheduling in interactive systems that apply when these assumptions are made is the round-robin (RR). RR is also one of the oldest, simplest and most widely used proportional share scheduling algorithms, and because of its usefulness, many proportional share scheduling mechanisms have been developed [1,4,[6][7][8][9][10][11]16]. In addition, RR algorithms have low scheduling overhead of O(1), which means scheduling the next task takes a constant time [3,5,15].
Briefly: RR scheduling dose not reorder the tasks but allows preemption to occur so that tasks that take longer than a designated time quantum are put to the back of the cyclic queue for processing at a later time. This paper elaborates the RR scheduling policy by allowing the time quantum to vary after each round through the cyclic queue. The terms task and job are used almost interchangeably in this text.
With the simple problem formulation, the main purpose of the proposed work is to minimize the following criteria: The main factor with the preemptive scheduler is the size of the time quantum. Setting the time quantum too short causes too many processes switches and lowers the CPU efficiency, but setting it too long may cause poor response to short interactive requests. A quantum around 20-50 msec is often a reasonable compromise [14].
Latest algorithms [2,12,17,18] try to modify RR by adjusting the time quantum. In the successive sections we will introduce how we can improve the round-robin algorithm by readjust ing the size of the time quantum to achieve the above criteria. In each round in the queue, the time quantum will be modified according to the burst times of the tasks. Using Changeable Time Quantum (CTQ) gives significant improvement in desired criteria.

CTQ Definitions
To provide a more in depth description of CTQ, we first define more precisely the state CTQ associates with each round, and then describe in detail how CTQ uses that state to schedule tasks. We define the terminology list we use in (Table 1).
The following equations determine the time quantum TQ that gives the smallest average waiting time in each round. TQ is ranged from α up to the given operating system time slice (OSTS), where α ≤ OSTS  3 ] is 0, although the number of context switches of T 1 is 1, the number of context switches of T 2 is 0, and the number of context switches of T 3 is 0.
T i Task i.

NTQ[Ti]=NTQi
The number of times the task Ti exploits the time quantum TQ.

BT[T i ]= BT i
The burst time of the task T i .

TQ
The time quantum.
n The number of the tasks.

SLTQ[Ti]
The starting of the last time quantum of T i .

WT[Ti]
The waiting time of task T i .

TWT
The total waiting time of all tasks.

AVGWT
The average waiting time of the tasks in the run queue.

RST[Ti]
The residual time of T i .
The changeable consideration CTQ combines the benefit of low overhead round-robin scheduling with low average response time and low average waiting time, this depends on the size of the preselected time quantum. If we have n tasks in a round r1 and m tasks that have burst times equal to or less than the time quantum used in r1, then there are n-m tasks in the next round, where n ≥ m. The residual time of the task T i in the round number q is determined from the equation: where TQ[k] is the time quantum in the round number k. In each successive round we implement the equations with respect to the residual times of the survived tasks. Figure 1 represents the pseudocode of the proposed algorithm.

Illustrative counter examples
To demonstrate the previous consideration we will take two cases of example. In the first one, the tasks arrive at the same time and in the second; the tasks arrive at different times. Consider the following set of tasks in (Table 3) that arrive at time 0, each of which with the length of the CPU burst time. 1 x     denotes the largest integer smaller than or equal to X.
When we apply the (CTQ) technique, the time quantum in the first round is equal to 25, TQ [ In this example there are three rounds; at each one a different time quantum is used. Table 4 gives each task waiting time, turnaround time and each task's response time. Now we will consider the above example when the tasks arrive at different arrival times. (Table 5) summarizes the burst time and arrival time of each task. We will compare the round-robin with fixed time quantum equal to 50 msec against our algorithm. (Tables 6, 7) show the policy of each algorithm.
In what follows, the number in parentheses in the comment field is the remaining service time for the process. In order of execution:      We modified this algorithm by sorting the tasks in each round in an ascending order to profit from knocking out short jobs relatively faster in a hope to increase the throughput and reduce the average waiting time [2,14]. Sorting tasks gives more improvement in scheduling criteria.

Simulation Studies and Results
This work is considered to be a modified RR algorithm in a small specific portion of the burst times of tasks. To demonstrate the effectiveness of the CTQ, we built a scheduling simulator that is a userspace program which takes five inputs, the scheduling algorithm, the number of tasks, the burst time, the arrival time of each task, and the first time quantum that will be used in the traditional round-robin. The simulator randomly assigns burst times and arrival times to tasks.
To measure the effectiveness, we ran simulations for the proposed algorithm against fixed round-robin algorithm and BRR [2] considered on 30 different combinations of n and BT's, the burst times of the tasks varying from 1 to Specific Burst Time(SBT) = 100 msec . For each set of (n, BT), we ran different number of tasks with different CPU lengths and different arrival times. In this research, the task arrival was modeled as a Poisson random process. Hence, the inter-arrival times are exponentially distributed. A task arrival generator was developed to take care of the process of random arrival of different tasks to the system. The generator produces the inter-arrival times utilizing some specific mean (arrival intensity) of the distribution function. We split our simulation into two cases; in the first case the tasks arrive at the same time, we call this set of 30 processes DATA1 and in the second case, the tasks arrive at different times. We call the second set of 30 processes DATA2.
To avoid unnecessary context switches, we ranged the selected TQ from α up to OSTS. Here in DATA1 and DATA2; OSTS is equal to 50 msec and α is equal to 1/2 OSTS. (Figures 2, 3 and 4) show the improvement of our algorithm over the two algorithms in first case, and ( Figures 5 and 7) show the improvement in second case.

Discussion
A lot of attempts were developed to find a solution for the high turnaround time, high waiting time and the overhead of extra context switches in round robin algorithm, regardless of the different methodologies used in these attempts; however all of them rely based on the fixed-time-quantum.
The proposed algorithm called Changeable Time Quantum (CTQ) based on dynamic-time-quantum was designed to solve all critical previously mentioned problems in a practical, simple and applicable manner.    The above comparisons show that the proposed algorithm provides much better results than other approaches based on fixed time quantum in all scheduling criteria.

Conclusion
In this study, a dynamic method was used to improve scheduling criteria in a uni-processor. In this work we don't use a fixed time quantum as usually used in scheduling algorithms, but we make the value of the time quantum changeable in each round according to the residual times of the tasks. The candidate time quantum in each round gives the smallest average waiting time consequently the smallest average turnaround time. Also we take into account the overhead resulting from the unnecessary context switches, so we try to keep the number of context switches as low as possible.