Download Round-robin: (RR) is one of the simplest scheduling

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quantum state wikipedia , lookup

Old quantum theory wikipedia , lookup

Quantum logic wikipedia , lookup

Transcript
NAME: OKE PETER
MATRIC NO: 13/SCI01/016
DEPARTMENT: COMPUTER SCIENCE
COUSRE CODE AND TITLE: CSC 203 OPERATING SYSTEM
LECTURER: MRS GBEMI BABALOLA
ROUND-ROBIN (RR) SCHEDULING
Round-robin: (RR) is one of the simplest scheduling algorithms for processes in an
operating system. It assigns time slices to each process in equal portions and in circular
order, handling all processes without priority. Round-robin scheduling is both simple and
easy to implement, and starvation-free. Round-robin scheduling can also be applied to
other scheduling problems, such as data packet scheduling in computer networks.
The name of the algorithm comes from the round-robin principle known from other
fields, where each person takes an equal share of something in turn.
In Round Robin Scheduling, the time quantum is fixed and then processes are scheduled
such that no process get CPU time more than one time quantum in one go. 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 unneces-sarily frequent
context switch leading to more overheads resulting in less throughput. In this paper, a method
using integer programming has been proposed to solve equations that decide a value that is
neither too large nor too small such that every process has reasonable response time and the
throughput of the system is not decreased due to un-necessarily context switches.
Different variants of Round Robin scheduling can be applied to other scheduling problems
such as data packet scheduling in computer networks. Effectiveness and efficiency of RR are
arising from its low scheduling overhead of (1), which means scheduling the next task takes a
constant time. In computer science, a scheduling algorithm is the method by which threads,
processes or data flows are given access to system resources (e.g. processor time,
communications bandwidth). This is usually done to load balance a system effectively or
achieve a target quality of service. The need for a scheduling algorithm arises from the
requirement for most modern systems to perform multitasking (execute more than one
process at a time) and multiplexing (transmit multiple flows simultaneously). Scheduling is a
key concept in computer multitasking, multiprocessing operating system and real-time
operating system designs. Scheduling refers to the way processes are assigned to run on the
available CPUs, since there are typically many more processes running than there are
available CPUs. Scheduling algorithms have been found to be NP-complete in general form
(i.e., it is believed that there is no optimal polyno-mial-time algorithm for them . Software
known as a scheduler and dispatcher carry out this assignment. The scheduler is concerned
mainly with: O
CPU utilization - to keep the CPU as busy as possible.
Throughput - number of processes that complete their execution per time unit.
Turnaround - total time between submission of a process and its completion.
Waiting time - amount of time a process has been waiting in the ready queue.
Response time - amount of time it takes from when a request was submitted until the first
response is produced.
Fairness - Equal CPU time to each thread.
It is similar to FCFS scheduling, but pre-emption is added to switch between processes. A
small unit of time, called a time quantum (or time slice), is defined. A time quantum is
generally from 10 – 100 milliseconds. The ready queue is treated as a circular queue. The
CPU scheduler goes around the ready queue, allocating the CPU to each process for a
time interval of up to 1 time quantum.
To implement the RR scheduling, we keep the ready queue as a FIFO queue of processes.
New processes are added to the tail of the queue. The CPU scheduler picks from the head
of the queue, sets a timer to interrupt after 1 time quantum, and dispatches the process.
One of two things will then happen. The process may have a CPU burst of less than one
time quantum. In which case the process itself releases the CPU voluntarily. The
scheduler will then proceed to the next process in the ready queue. Otherwise, if the CPU
burst of the currently running process is longer than 1 time quantum, the timer will go off
and will cause an interrupt to the operating system. A context switch will be executed,
and the process will be put at the tail of the ready queue. The scheduler then selects the
next process in the ready queue.
The average waiting time under RR policy is often quite long.
Example 3.5: Consider the following set of processes, assumed to have arrived at time 0,
in the order P1, P2, P3, with the length of the CPU-burst time given in milliseconds:
If
PROCESS
P1
P2
P3
BURST TIME
24
3
3
If we use a time quantum of 5 milliseconds, we would schedule these processes
according to the Gantt chart below:
P1
0
P2
5
P3
8
P1
11
P1
16
P1
21
P1
26
30
The average waiting time is 17/3 = 5.66 milliseconds.
In RR scheduling algorithm, no process is allocated the CPU for more than 1 time
quantum in a row. If a process’ CPU burst exceeds 1 time quantum, that process is preempted and is put back in the ready queue. The RR scheduling algorithm is
Pre-emptive.
The main advantage of round robin algorithm over first come first serve algorithm is that it
is starvation free . Every process will be executed by CPU for fixed interval of time (which is
set as time slice ) . So in this way no process left waiting for its turn to be executed by the
CPU . Round robin algorithm is simple and easy to implement . The name round robin comes from
the principle known as round robin in which every person takes equal share of something in turn .
Pseudo Code :
* CPU scheduler picks the process from the circular/ready queue , set a timer to interrupt it
after 1 time slice / quantum and dispatches it .
* If process has burst time less than 1 time slice/quantum
> Process will leave the CPU after the completion
> CPU will proceed with the next process in the ready queue / circular queue .
else If process has burst time longer than 1 time slice/quantum
> Timer will be stopped . It cause interruption to the OS .
> Executed process is then placed at the tail of the circular / ready querue by
applying the context
switch
> CPU scheduler then proceeds by selecting the next process in the ready queue .
Here , User can calculate the average turnaround time and average waiting time along with
the starting and finishing time of each process
Turnaround time : Its the total time taken by the process between starting and the
completion
Waiting time
scheduler
: Its the time for which process is ready to run but not executed by CPU
for example ,
we have three processes
Burst time
Waiting time
Turnaround time
P1
24
6
30
P2
3
4
7
P3
3
7
10
So here we can see the turnaround time for the process 1 is 30 while 7 and 10 for 2nd and 3rd
process.
A Gantt chart is a chart which shows the start and finish times of all the processes .
Gantt chart for the round robin algorithm is
P1
0
P2
4
P3
7
P1
10
P1
14
P1
18
P1
22
P1
26
30
The major features of the Round Robin algorithm :
* Throughput is low as the large process is holding up the Central processing unit for execution .
* The main advantage of Round robin is to remove starvation . As long as all processes completes
the execution then we dont have any trouble, But the problem starts when any of the process fails
to complete . The incomplete execution of any process leads to starvation .
* Queuing is done without using any prioritization of the processes.