Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Interactive System

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

INTERACTIVE SYSTEM

Round Robin(RR) Scheduling Algorithm


Round Robin CPU Scheduling is the most important CPU Scheduling Algorithm. Round Robin
CPU Scheduling uses Time Quantum (TQ). The Time Quantum is something which is removed
from the Burst Time and lets the chunk of process to be completed.
Time Sharing is the main emphasis of the algorithm. The system defines a specific time slice,
known as a time quantum.
First, the processes which are eligible to enter the ready queue enter the ready queue. After
entering the first process in Ready Queue is executed for a Time Quantum chunk of time. After
execution is complete, the process is removed from the ready queue. Even now the process
requires some time to complete its execution, then the process is added to Ready Queue.
The Ready Queue does not hold processes which already present in the Ready Queue. The Ready
Queue is designed in such a manner that it does not hold non unique processes. By holding same
processes Redundancy of the processes increases.
After, the process execution is complete, the Ready Queue does not take the completed process
for holding.
Advantages
The Advantages of Round Robin CPU Scheduling are:
1. A fair amount of CPU is allocated to each job.
2. Because it doesn't depend on the burst time, it can truly be implemented in the system.
3. It is not affected by the convoy effect or the starvation problem as occurred in First Come
First Serve CPU Scheduling Algorithm.
Disadvantages
The Disadvantages of Round Robin CPU Scheduling are:
1. Low Operating System slicing times will result in decreased CPU output.
2. Round Robin CPU Scheduling approach takes longer to swap contexts.
3. Time quantum has a significant impact on its performance.
4. The procedures cannot have priorities established.
Examples:
Process ID Arrival Time Burst Time
______ ______ _______
P1 0 7
P2 1 4
P3 2 15
P4 3 11
P5 4 20
P6 4 9
Assume Time Quantum TQ = 5
Ready Queue:
P1, P2, P3, P4, P5, P6, P1, P3, P4, P5, P6, P3, P4, P5
Gantt chart:
Average Completion Time
Average Completion Time = ( 31 +9 + 55 +56 +66 + 50 ) / 6
Average Completion Time = 267 / 6
Average Completion Time = 44.5
Average Waiting Time
Average Waiting Time = ( 5 + 26 + 5 + 42 + 42 + 37 ) / 6
Average Waiting Time = 157 / 6
Average Waiting Time = 26.16667
Average Turn Around Time
Average Turn Around Time = ( 31 + 8 + 53 + 53 + 62 + 46 ) / 6
Average Turn Around Time = 253 / 6
Average Turn Around Time = 42.16667

Highest Response Ratio Next (HRRN) Scheduling


Highest Response Ratio Next (HRNN) is one of the most optimal scheduling algorithms. This is
a non-preemptive algorithm in which, the scheduling is done on the basis of an extra parameter
called Response Ratio. A Response Ratio is calculated for each of the available jobs and the Job
with the highest response ratio is given priority over the others.
Response Ratio is calculated by the given formula.
Response Ratio = (W+S)/S
Where,
W → Waiting Time
S → Service Time or Burst Time
Algorithm of HRNN
 In the HRNN scheduling algorithm, once a process is selected for execution will run until
its completion.
 The first step is to calculate the waiting time for all the processes. Waiting time simply
means the sum of the time spent waiting in the ready queue by processes.
 Processes get scheduled each time for execution in order to find the response ratio for
each available process.
 Then after the process having the highest response ratio is executed first by the processor.
 In a case, if two processes have the same response ratio then the tie is broken using the
FCFS scheduling algorithm.
In the following example, there are 5 processes given. Their arrival time and Burst Time are
given in the table.
Process ID Arrival Time Burst Time

0 0 3

1 2 5

2 4 4

3 6 1

4 8 2
At time 0, The Process P0 arrives with the CPU burst time of 3 units. Since it is the only process
arrived till now hence this will get scheduled immediately.

P0 is executed for 3 units, meanwhile, only one process P1 arrives at time 3. This will get
scheduled immediately since the OS doesn't have a choice.

P1 is executed for 5 units. Meanwhile, all the processes get available. We have to calculate the
Response Ratio for all the remaining jobs.
RR (P2) = ((8-4) +4)/4 = 2
RR (P3) = (2+1)/1 = 3
RR (P4) = (0+2)/2 = 1
Since, the Response ratio of P3 is higher hence P3 will be scheduled first.
P3 is scheduled for 1 unit. The next available processes are P2 and P4. Let's calculate their
Response ratio.
RR ( P2) = (5+4)/4 = 2.25
RR (P4) = (1+2)/2 = 1.5
The response ratio of P2 is higher hence P2 will be scheduled.

Now, the only available process is P4 with the burst time of 2 units, since there is no other
process available hence this will be scheduled.

Process Arrival Burst Completion Turn Around Waiting


ID Time Time Time Time Time

0 0 3 3 3 0

1 2 5 8 6 1

2 4 4 13 9 5

3 6 1 9 3 2

4 8 2 15 7 5
Average Waiting Time = 13/5

You might also like