Untitled
Untitled
ABSTRACT
iii
In operating system the performance of the CPU is mainly based on scheduling algorithm which
depends on waiting time, response time, turnaround time, context switches. Here Time Quantum plays a
very important role in this process. Round Robin CPU scheduling algorithm depends on time quantum
which is pre-defined. The time quantum is calculated from the burst time of the set of waiting processes in
the ready queue. In this project, a new round robin scheduling algorithm has been proposed where time
quantum is allocated dynamically. In this algorithm the main idea is to produce better average waiting time
and average turnaround time and number of context switches leads to increase in system performance. The
experimental results show that the proposed algorithm solves the fixed time quantum problem and decrease
the average waiting time and turnaround time compared to traditional Round Robin algorithm.
Keywords
Round Robin, Dynamic time quantum, Arrival time, Burst time, Average Waiting time, Response
time, Average Turnaround time, Context switche
iv
vi
CHAPTER 1
INTRODUCTION
1.1 Objective:
An operating system is a program that manages the computer hardware and provides a basis for application
programs and acts as an intermediary between the computer user and the computer hardware The CPU
executes multiple jobs by switching among them in multi-programmed system. The objective is to increase
the CPU utilization by allowing new jobs to take over the CPU whenever the presently running job needed to
wait In multiprogramming operating system, process scheduling is an important way that increases system
performance by selecting a waiting process from ready queue and assigns the CPU to this selected process.
More specifically proposed an algorithm that calculates the original time slice which is suitable to the burst
time of each processes and then dynamic ITS (Intelligent Time Slice) is found out in conjunction with the
SRTN algorithm. Calculated the optimal time quantum from the average of highest CPU burst time and the
median and assigned it to each process after every cycle of execution. The proposed an algorithm known as
AN, based on a new approach called dynamic-time-quantum, that take the mean average of burst time of
waiting processes as time quantum and updated this time quantum after one process completes its execution
through one time quantum. The CPU is assigned to the first process of the ready queue for a time interval of
up to one time quantum in an improved Round Robin (IRR) CPU scheduling algorithm . After completing its
one-time quantum, if the remaining burst time of the currently running process is less than one-time
quantum, the CPU is again allocated to the same process. Otherwise, CPU is assigned to another waiting
process. Later, IRRVQ (IRR with Varying time Quantum) algorithm is proposed by Mishap & Rashid (2014)
for CPU scheduling. This method arranges the processes in the ready queue in the ascending order of their
remaining burst time and set the time quantum value equal to the burst time of first process in the ready
queue.
The CPU scheduler chooses a process to allocate the CPU for a fixed length of
time quantum for all processes of the ready queue in RR (Silberschatz et al. (2005), Noon et al. (2011), Yang
et al. (2003), Roy et al. (2017), Nitu et al. (2015)). This process continues repeatedly until ready queue
becomes empty. Here, the quantum is a very small-time value which is set for preemption of the processes
(Roy et al. (2017)). By this algorithm, the processes can execute concurrently (Silberschatz et al. (2005), Roy
et al. (2017)). If the time quantum is too large, the response time of the processes becomes too high. On the
other hand, if this time quantum is too small, it decreases response time but increases the amount of context
switch among the processes (Noon et al. (2011)). Hence, RR with fixed time quantum may decrease the
performance of a multitasking system in several times. This paper introduces a modified algorithm named
1
Round Robin with Dynamic Time Quantum (RRDTQ) that uses dynamic time quantum in CPU scheduling
along with RR. This time quantum is equivalent to the integer average value of the burst time of the
remaining waiting processes in the ready queue. 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. The experimental results show
that the proposed algorithm minimizes the average waiting time, average turnaround time and amount of
context switch among the processes with comparison that of the traditional RR, and recently proposed AN
(Noon et al. (2011)) and IRRVQ (Mishra & Rashid (2014)) algorithms. Hence, the commuter system will be
more productive by implementing the proposed algorithm.
2
CHAPTER 2
SYSTEM ANALYSIS
In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This
algorithm also offers starvation free execution of processes.
3
Algorithm:
Step 1: Organize all processes according to their arrival time in the ready queue. The queue structure of the
ready queue is based on the FIFO structure to execute all CPU processes.
Step 2: Now, we push the first process from the ready queue to execute its task for a fixed time, allocated by
each process that arrives in the queue.
Step 3: If the process cannot complete their task within defined time interval or slots because it is stopped by
another process that pushes from the ready queue to execute their task due to arrival time of the next process is
reached. Therefore, CPU saved the previous state of the process, which helps to resume from the point where it
is interrupted. (If the burst time of the process is left, push the process end of the ready queue).
Step 4: Similarly, the scheduler selects another process from the ready queue to execute its tasks. When a
process finishes its task within time slots, the process will not go for further execution because the process's
burst time is finished.
Step 5: Similarly, we repeat all the steps to execute the process until the work has finished.
Let's understand the concepts of Round Robin with an example. Suppose we have five processes P1, P2, P3, P4
and P5. The arrival and burst time of each process are mentioned in the following table, as shown below. The
time quantum is three units.
P1 0 8
P2 5 2
P3 1 7
P4 6 3
4
P5 8 5
Fig 2.1.1 Arrival and burst time of processes
Now we have to create the ready queue and the Gantt chart for Round Robin CPU Scheduler.
Ready queue: P1, P3, P1, P2, P4, P3, P5, P1, P3, P5
5
Step 1: At time 0, process P1 enters the ready queue and starts its execution for the defined time slot 3. During
3 units of the time slice, another process, P3, arrives in the ready queue because its arrival time is 1.
Step 2: Now, process P3 starts its execution with a time slot of 3 units while process P1 has to wait. After
execution of process P3, process P1 again resumes its execution for time slot 3.
Step 3: During the execution of process P1, two more processes P2 and P4, arrive in the ready queue to begin
their execution. Since process P2 has come first, it will be executed for time quantum 2 units after that P4 is
executed.
Step 4: Here, P4 has executed for time slot 3 units, and its task is completed because BT (Burst Time) is 2.
Hence it will not go to the ready queue.
Step 5: After that, process P3 is executed from the ready queue for time slot 3 and then process P5 arrives for
time slot 3.
Step 6: Meanwhile, process P5 is executed, process P1 and P3 have to wait in the ready queue.
Step 7: Now process P1 is fetched from the ready queue and starts their execution for time slot 2 as it requires
only 2 BT to finish its tasks. Hence it will not go to the ready queue for further execution.
Step 8: Now, the process P3 is executed for time slot 1 as it requires only 1 BT to complete its tasks.
Step 9: The final process P5 is executed for time slot 2 because it requires only 2 BT to complete its tasks.
The following are the important terms to find the Completion time, Turn Around Time (TAT)
1. Completion Time: It defines the time when processes complete their execution.
2. Turn Around Time: It defines the time difference between the completion time (CT) and the arrival
time (AT).
Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
3. Waiting Time: It defines the total time between requesting action and acquiring the resource.
Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
4. Response Time: It is the time that defines at which time the system response to a process.
6
Process Arrival Burst Completion Turn Waiting Response
Time Time Time Around Time Time
Time
P1 0 8 22 22 14 0
P2 5 2 11 6 4 4
P3 1 7 23 22 15 2
P4 6 3 14 8 5 5
P5 8 5 25 17 12 9
Turn Around Time for P1 = Completion Time (CT) - Arrival Time (AT)
=22 - 0 = 22
Turn Around Time for P2 = 11 - 5 = 6
Turn Around Time for P3 = 23 - 1 = 22
Turn Around Time for P4 = 14 - 6 = 8
Turn Around Time for P5 = 25 - 8 = 17
Waiting Time for P1 = Turn Around Time (TAT) - Burst Time (BT)
22 - 8 = 14
Waiting Time for P2 = 6 - 2 = 4
Waiting Time for P3 = 22 - 7 = 15
Waiting Time for P4 = 8 - 3 = 5
Waiting Time for P5 = 17 - 5 = 12
7
Average Waiting Time = (14 + 4 + 15 + 5 + 12)/5 = 50/5 = 10
Let's understand another example of Round Robin with sequential arrival time. Here we have four
processes P1, P2, P3, and P4. The arrival and burst time of each process are mentioned in the following table, as
shown below. The time quantum is 6 units.
P1 0 8
P2 1 5
P3 2 10
P4 3 11
8
Fig 2.1.5 Gantt chart
Step 1: At time 0, process P1 arrives in the ready queue and executes its tasks for time quantum 6 units. During
6 units of the time slice, another process P2, P3 and P4 arrive in the ready queue. After that, process P1 will
return to the end of the ready queue and await their execution.
Step 2: Now, process P2 starts their execution for time slot 5 units because the Burst Time (BT) is 5, and it does
not go to the ready queue for further execution.
Step 3: After that process, P3 will start its execution, which has 10 Burst time, but the time quantum is 6 units.
Therefore, it executes its tasks for a defined time limit and is added to the ready queue's end.
Step 4: After that, the process P4 starts their execution, which has burst time 11, but the time quantum is 6
units. It executes its tasks for only 6 seconds and then adds to the end of the ready queue.
Step 5: After the execution of P4, now P1 will start its execution again for 2 units or second, and the process P1
terminate or end. Similarly, the complete execution of process P1, then P3, starts its remaining execution for
Burst Time 4, and the process is completed.
Step 6: After the complete execution of process P3, now process P4 executes for the remaining time slot, which
is 5, and the process is finished.
9
P1 0 8 25 25 17
P2 1 5 11 10 5
P3 2 10 29 27 17
P4 3 11 34 31 20
Now we find the completion, Turn around time, waiting time and the average TAT and waiting time.
P1 = 25-8 =17
P2 = 10-5 =5
P3 = 27-10= 17
10
P4= 31-11=20
Average Waiting Time is: (17+5+17+20)/4 = 59/4 = 14.75
CHAPTER 3
PROJECT DESCRIPTION
Step 3. Set the time quantum value equal to the integer of average burst time of the processes in the RQUEUE.
Step 4. Repeat steps 5to7 until all processes in the ready queue get the CPU time interval up to 1 time
quantum.
Step 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.
Step 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.
Step 7. Else, put it at the tail of the ready queue with the remaining required burst Time.
Figure 1, 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.
TQ=10
P1 P2 P3 P4 P5 P1 P2 P4 P5 P2 P4 P2
0 10 20 30 40 50 55 65 75 85 95 101 103
Time(ms)
TQ=5
P1 P2 P3 P4 P5 P1 P2 P3 P4 P5 P1
0 5 10 15 20 25 30 35 40 45 50 55
TQ=5
13
P2 P4 P5 P2 P4 P5 P2 P4 P2 P4 P2
55 60 65 70 75 80 85 90 95 100 101 103
Time(ms)
TQ=6
P1 P2 P3 P4 P5 P1 P2 P3 P4 P5
0 6 12 18 24 30 36 42 46 52 58
TQ=6
P1 P2 P4 P5 P2 P4 P5 P2 P4 P2
58 61 67 73 79 85 91 93 99 101 103
Time (ms)
P3 P1 P5 P4 P2 P4 P2 P2
0 10 25 45 65 85 91 100 103
Time(ms)
Figure 4: - Gantt chart representation of Proposed Round robin Dynamic time quantum Algorithm
From 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
15
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 3, 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+65+25)/5=34.2 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.
Table 2 shows the comparative analysis of Round Robin and Proposed RRDTQ Algorithm that are
introduced in this paper. It is seen that the average waiting times are 54.2, 56.2 and 60.2 milliseconds for Round
Robin with 10, 5 and 6 milliseconds time quantum respectively. On the other hand, our proposed RRDTQ
algorithm requires only the average waiting times of 34.2 milliseconds for processes shown in table 1.
Besides, the average turnaround times are 74.8, 76.8 and 80.8 milliseconds for Round Robin with 10,
5 and 6 milliseconds time quantum respectively for the processes shown in table-1. On the other hand, our
proposed RRDTQ algorithm requires only the average turnaround times of 54.8 milliseconds.
Table 2 also shows that Round Robin algorithm with 10, 5 and 6 milliseconds time quantum acquire 11, 21 and
19 times context switching for executing the processes. RRDTQ requires 6 times context switching for
executing the processes. Hence the proposed algorithm decries the average waiting time, average turnaround
16
time and amount of context switch among the processes than the traditional RR algorithm and enhances the
CPU performance.
Figure 4 and Figure 5 show the Gantt charts for simple round robin algorithm with time quantum of
10 and 15 milliseconds respectively. Finally, Figure 6 shows the Gantt chart representation of the proposed
RRDTQ algorithm with dynamic time quantum and the comparison result of RR the proposed RRDTQ
algorithm is shown in Table 4.
TQ=10
P1 P2 P3 P4 P5 P1 P2 P4 P5 P2 P4 P4
0 10 20 30 40 50 58 68 78 82 85 95 100
Time(ms)
Figure 4: - Gantt chart representation of RR with TQ = 10
TQ=15
P1 P2 P3 P4 P5 P1 P2 P4 P4
0 15 30 40 55 69 72 80 95 100
Time(ms)
P1 P3 P5 P2 P4 P2 P4 P4
0 18 28 42 62 82 85 94 100
Time(Ms)
P1 18 18 0
P2 85 85 59
P3 28 24 14
P4 100 92 57
18
P5 42 32 18
AVERAGE AVERAGE WAITING
TURNAROUND TIME=148/5=29.6
TIME=248/5=49.6
From Table3, processes P1, P2, P3, P4, and P5 have the length of the CPU burst 18, 23, 10, 35, 14
respectively and arrived at 0, 3, 4, 8 and 10 respectively in ready queue. At 0 millisecond, the ready queue
contains only P1 process. 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.
CHAPTER 4
SYSTEM SPECIFICATION
Hardware Specification:
Computer hardware specifications are technical descriptions of the computer's components and
capabilities .Processor speed, model and manufacturer. Processor speed is typically indicated in gigahertz
20
(GHz).The higher the number, the faster the computer. Random Access Memory (RAM) , This is typically
indicated in gigabytes (GB). The more RAM in a computer the more it can do simultaneously. Hard disk
(sometimes called ROM) space. This is typically indicated in gigabytes (GB) and refers generally to the
amount of information (like documents, music and other data) your computer can hold. Other specifications
might include network (ethernet or wi-fi) adapters or audio and video capabilities
Processor: Minimum 1 GHz; Recommended 2GHz or intel core i7
Ethernet connection (LAN) OR a wireless adapter (Wi-Fi)
Hard Drive: Minimum 32 GB; Recommended 64 GB or 1TB
Memory (RAM): Minimum 1 GB; Recommended 4 GB or above.
Software Specification:
A System Requirements Specification (SRS) (also known as a Software Requirements Specification) is
a document or set of documentation that describes the features and behavior of a system or software application.
It includes a variety of elements (see below) that attempts to define the intended functionality required by the
customer to satisfy their different users.
Operating system: Windows10 (32 bit)
Programming language: Java
Compiler: JDK (Java Development Kit)
IDE: IntelliJ IDEA
21