A MODIFIED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH DYNAMIC TIME QUANTUM

Md. Sohrawordi 1 , U. A. Md. Ehasn Ali 1 , Md. Palash Uddin 1 and Md. Mahabub Hossain 2 . 1. Department of Computer Science and Engineering, Hajee Mohammad Danesh Science and Technology University, Dinajpur-5200, Bangladesh. 2. Department of Electronics and Communication Engineering, Hajee Mohammad Danesh Science and Technology University, Dinajpur-5200, Bangladesh. ...................................................................................................................... Manuscript Info Abstract ......................... ........................................................................ Manuscript History Received: 05 December 2018 Final Accepted: 07 January 2019 Published: February 2019

CPU scheduling is one of the basic factors for performance measure of multitasking operating system which makes a commuter system more productive by switching the CPU among the processes. The performance of the CPU scheduling algorithms depends on minimizing waiting time, response time, turnaround time and context switching, and maximizing CPU utilization. Round Robin (RR) is the most widely used CPU scheduling algorithm in multitasking operating system. The efficiency of a multitasking systemcomprising with Round Robin CPU scheduling relies onthe selection of the optimal time quantum. If the time quantum is longer, the response time of the processes becomes too high. On the other hand, the shorter time quantum raises the amount of context switch among the processes. In this paper, a modified CPU scheduling algorithm, called Round Robin with Dynamic Time Quantum (RRDTQ) is introduced for enhancing CPU performance using dynamic time quantum with RR. This time quantum is calculated from the burst time of the set of waiting processes in the ready queue. The experimental results show that the proposed algorithm solves the fixed time quantum problem and decreases the average waiting time and turnaround time compared to traditional RR algorithm. 423 There are different kinds of algorithms implemented in CPU scheduling of operating system. Among them, Round Robin (RR) algorithm is most widely used in multiprogramming operating system (Noon et al. (2011), Yang et al. (2003), Padhy&Nayak (2014)).Various approaches are introduced for enhancing the performance of RR scheduling. Goyal et al. (2011) have arranged the processes in the ready queue in ascending order of burst time and taken the median of the burst time of the processes as time quantum for each cycle. Other reports proposed a fixed time quantum is taken for the waiting process in the ready queue only for first cycle, and then SJF is used to select next process (Yadav et al. (2010)).After arranging the processes in ascending order of burst time, the CPU burst of the mid process in case of odd number of processes is selected as time quantum; otherwise the average CPU burst of all running processes is taken time quantum in (Hiranwal et al. (2011)). Researchers, moreover, have taken the average of minimum and maximum burst time of the processes in the ready queue as time slice (Behera et al.  (2014)) algorithms. Hence, the commuter system will be more productive by implementing the proposed algorithm.

Proposed RRDTQ CPU Scheduling Algorithm
The proposed RRDTQ algorithm uses dynamic time quantum in CPU scheduling. It takes the integer average value of the burst time of the remaining waiting processes in the ready queue as time quantum. After each cycle, the time quantum is updated by calculating the integer average value of the burst time of the processes in the ready queue. If the ready queue contains only one waiting process, then the time quantum will be the burst time of that processes. When the execution of the processes is completed, then it will be removed from ready queue and otherwise it will be added at the tail of the ready queue with the remaining required burst time. Following is the proposed RRDTQ CPU scheduling algorithm. 1. Create a ready queue RQUEUE of the processes that are ready for execution. 2. Repeat following steps 3to7 while RQUEUE is not empty. 3. Set the time quantum value equal to the integer of average burst time of the processes in the RQUEUE. 4. Repeat steps 5to7 until all processes in the ready queue get the CPU time interval up to 1 time quantum. 5. Pick the process that requires smallest CPU burst time among processes in RQUEUE and allocate CPU to this process for a time interval of up to 1 time quantum. 424 6. If the currently running process has finished its execution and the remaining CPU burst time of the currently running process is zero, then remove it from ready RQUEUE. 7. Else, put it at the tail of the ready queue with the remaining required burst time.

Experimental Result Analysis: -Assumptions
For experimental analysis, all processes are treated having equal priority ina single processor environment. The time for context switching from one process to another is zero and all processes are CPU bound. There are noprocesses that are I/O bound. The number of processes and their burst time are known before submitting the processes for the execution. The time quantum for the proposed algorithm is taken in milliseconds.

Performance Evaluation
Two different cases have been taken for performance evaluation of the proposed RRDTQalgorithm. In the case 1, all processes arrival time is assumed same and in the case 2, processes arrival time isassumed different.

CASE 1 -Same Arrival Time
In this case, all processes are arrived at same time in ready queue. Now, consider a ready queue with five processes P1, P2, P3, P4, and P5 as shown in Table 1, assumed to have arrived at time 0 millisecond (ms) with the length of the CPU burst given in milliseconds.  Figure 2 and Figure 3 show Gantt charts for simple round robin algorithm with time quantum of 10, 5 and 6 milliseconds respectively. Figure 4 and Figure 5 show the Gantt chart representation of AN and IRRVQ algorithms. Figure 6 shows the Gantt chart representation of the proposed RRDTQ algorithm with dynamic time quantum and the comparison result of RR, AN, IRRVQ and the proposed RRDTQ algorithm is shown in Table 2.   Table 1, processes P1, P2, P3, P4, and P5 have the length of the CPU burst time 15, 32, 10, 26 and 20 respectively. Then, the time quantum of the Proposed Round Robin will be the integer average value (103/5=20) of the CPU burst time. At first, the CPU is assigned to the process P3 for 10 milliseconds (ms), because it has minimum CPU burst time among the processes in the ready queue. After P3, the process P1 is executed through 15 ms, each P5, P4 and P4 processes run through 20 ms respectively in first time quantum. Now, the ready queue contains P2 and P4 processes with the CPU burst 12, 6 respectively. So, the time quantum will be upgraded to the integer average value (18/2=9) of the CPU burst of process P2 and P4. Finally, P2 runs through 6 ms, because it requires shorter CPU burst time then P4 and then P4 executes. Now, form the Gantt chart representation shown in Figure 6, it is seen that the waiting time using the proposed RRDTQ is 10 milliseconds for process P1, 71 milliseconds for process P2, 0 milliseconds for process P3, 71 milliseconds for process P4 and 25 milliseconds for process P5. Thus, the average waiting time is (10+71+0+71+25)/5=35.4 milliseconds. It is also seen that the turnaround time for the processes P1, P2, P3, P4, and P5 are 25, 103, 10, 91and 45 milliseconds respectively. Thus, the average turnaround time is (25+103+10+91+45)/5=54.8 milliseconds.
426   Table 2 also shows thatRound Robin algorithm with 10, 5 and 6 milliseconds time quantum acquire 11, 21 and 19 times context switching for executing the processes. AN, IRRVQ andRRDTQrequires 10, 14 and 6 times context switching for executing the processes. Hence the proposed algorithm decries the average waiting time, average turnaround time and amount of context switch among the processes than the traditional RR, AN and IRRVQ algorithm and enhances the CPU performance.

CASE 2 -Different Arrival Time
In this case, all processes are arrived at different time in ready queue. Now, consider a ready queue with five processes P1, P2, P3, P4, and P5 as shown in table 3, assumed to have arrived at various time with the length of the CPU burst given in milliseconds.  Figure 7 and Figure 8 show the Gantt charts for simple round robin algorithm with time quantum of 10 and 15 milliseconds respectively. Figure 9 and Figure 10 show the Gantt charts representation of AN and IRRVQ algorithms. Finally, Figure 11 shows the Gantt chart representation of the proposed RRDTQ algorithm with dynamic time quantum and the comparison result of RR, AN, IRRVQ and the proposed RRDTQ algorithm is shown in Table  4.   Thus, the time quantum for the proposed RRDTQ algorithm will be the burst time of P1 process. Hence, the CPU is assigned to the process P1 for 18 milliseconds. Now, the ready queue contains P2, P3, P4, and P5 processes. The time quantum of the proposed RRDTQ algorithm will be the integer average value (82/4=20) of the CPU burst time. At first, the CPU is assigned to the process P3 for 10 milliseconds (ms), because it has minimum CPU burst time among the processes in the ready queue. After P3 the process P5 is executed through 14 ms and then P1 is executed through 18 ms. Finally, each P2 and P4 processes run through 20 ms in first time quantum. Now, the ready queue contains P2 and P4 processes with the CPU burst 3, 15 respectively. In this manner, the time quantum will be upgraded to the integer average value (18/2=9) of the CPU burst of processes P2 and P4. Finally, P2 runs through 3 ms, because it has shorter CPU burst time then P4 and then P4 executes.  Now, from the Gantt chart representation as shown in Figure 11, it is seen that the waiting time using the proposed RRDTQ are 0, 59, 14, 57 and 18 milliseconds for process P1, P2, P3, P4, and P5 respectively. It is also seen that the turnaround time for the processes P1, P2, P3, P4, and P5 are 18, 82, 24, 92 and 32 milliseconds respectively. Thus, the average turnaround time is (18+82+24+92+32)/5=49.2 milliseconds.
In this way, the experimental results shown in Table 4 prove that the proposed algorithm requires less average waiting time, less average turnaround time and less amount of context switch among the processes than the traditional RR, AN and IRRVQ algorithms. Hence, the CPU performance can be enhanced by implanting our proposed algorithm.

Conclusion:-
The allocation of CPU to the processes waiting for execution is the most important tasks of the operating system. Because the CPU is most valuable computer resource. There are many kinds of CPU scheduling algorithms that have been presented to manage the CPU with some advantages and disadvantages. This paper presents a new CPU scheduling algorithm with varying dynamic time quantum. The comparison results of round robin (RR), AN, IRRVQ and the proposed algorithm RRDTQ have been investigated in this paper. This comparison proves that the proposed RRDTQ algorithm is more efficient than the conventional RR, AN and IRRVQ algorithms. Because it acquires less average waiting time, less average turnaround time and a smaller number of context switches than that of the RR, AN and IRRVQ. Therefore, the proposed algorithm is demonstrated to enhance the performance of multitasking operating systems.