round robin scheduling

16
ROUND ROBIN SCHEDULING MODEL WITH TIME SLICING

Upload: raghav-s

Post on 12-Apr-2017

401 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Round robin scheduling

ROUND ROBIN SCHEDULING MODEL WITH TIME SLICING

Page 2: Round robin scheduling

SCHEDULING AND ITS TYPES Scheduling is a method by which threads, processes or data flows are given access

to system resources. The need for scheduling algorithm arises from the requirement for most modern

systems to preform multitasking and multiplexing. The common scheduling models are:1. Cooperative Scheduling of ready tasks in a circular queue2. Cooperative Scheduling with Precedence Constraints3. Cyclic scheduling of periodic tasks and Round Robin Time Slicing

Scheduling4. Pre-emptive Scheduling5. Scheduling using ‘Earliest Deadline First’ (EDF) precedence6. Rate Monotonic Scheduling using ‘higher rate of events occurrence First’ precedence7. Fixed Times Scheduling8. Scheduling of Periodic, sporadic and aperiodic Tasks 9. Advanced scheduling algorithms using the probabilistic Timed Petri nets (Stochastic)

or Multi Thread Graph for the multiprocessors and complex distributed systems

Page 3: Round robin scheduling

CYCLIC SCHEDULING

A cyclic scheduling model is a scheduling concept in which a set of activities are repeated an indefinite number of times.

Let us assume that we have periodically occurring three tasks. Let the first task execute at time frames t1,t1+(Tcycle), t1+(2Tcycle) …

The second task occurs at t2, t2 +(Tcycle), t2+(2Tcycle) …The third task occurs at t3, t3+Tcycle, t3+(2Tcycle)…

Tcycle is the time for repeating the cycle of execution of tasks in order 1,2,3 and equals start of task 1 time frame to end of task 3 time frame.

Tcycle is period after which each task time frame allotted to that repeats. Each task has the same priority for execution in the cyclic mode. Cycling scheduling is very efficient for handling periodic tasks when the

number of tasks is small.

Page 4: Round robin scheduling

An example of cyclic scheduling is Orchestra Playing Robots.

First the director robot sends the musical notes. Then, the playing robots receive and acknowledge to the director.

In next cycle, the master robot again sends the musical notes.

The cyclic scheduler is used in this case to send and receive signals by each robot after the cycle period.

Page 5: Round robin scheduling

ROUND ROBIN SCHEDULING Round robin is one of the oldest, simplest and fairest algorithm. Widely used model in traditional OS. 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.

Round robin means that each ready task runs turn by turn only in a cyclic queue for a limited time slice, Tslice.

Tslice = Tcycle/ N

N= Number of tasks Time slice is minimum time assigned for each task to be processed.

It can vary for different processes. Round robin is a hybrid model of clock-driven model (for example, cyclic

model) as well as event driven (for example, pre-emptive). A real time system responds to the event within a bound time limit and

within an explicit time.

Page 6: Round robin scheduling

UNDERSTANDING ROUND ROBIN WITH AN EXAMPLE

Suppose after every 20ms there is a stream of coded messages reaching Port A of an embedded system. The multiple processes consist of 5 tasks as follows

Page 7: Round robin scheduling

Time slicing is done as follows:

Page 8: Round robin scheduling

WORST CASE LATENCY

Worst case latency is the maximum time taken for execution of all the tasks. Tworst = {(dti+ sti + eti )1 + (dti+ sti + eti )2 +...+ (dti+ sti + eti )N-1 + (dti+ sti + eti )N} + tISR Where,dt = detection time when a task is brought into the listst = switching time from one task to anotheret = task execution time tISR = sum of all execution times for the ISRs

Page 9: Round robin scheduling

CASE 1

Let us consider the case where each task is executed once and finishes off in one cycle itself.

When a task finishes the execution before the maximum time it can take, there is a waiting period between two cycles.

The worst-case latency for any task is then, Tworst = N X tslice . A task may periodically need execution. The period for the required

repeat execution of a task is an integral multiple of tslice.

Page 10: Round robin scheduling

CASE 2: ALTERNATIVE MODEL STRATEGY

In Case 2 we have certain tasks which are executed more than once and do not finish in one cycle.

Alternate model strategy includes decomposition of a task that takes the abnormally long time to be executed.

The decomposition can be into two or four or more tasks. Then one set of tasks (say the odd numbered tasks) can run in one

time slice, t'slice and the another set of tasks (say the even numbered tasks) can run in another time slice, t''slice .

Page 11: Round robin scheduling

CASE 3: DECOMPOSITION INTO A NUMBER OF SEQUENTIAL STATES

Another alternate strategy is decomposition of the long time taking task into a number of sequential states or a number of node-places and transitions as in finite state machine (FSM).

Then one of its states or transitions can run in the first cycle, the next state in the second cycle and so on.

This task then reduces the response times of the remaining tasks that are executed after a state change.

Page 12: Round robin scheduling

VoIP EXAMPLE Consider a VoIP (Voice Over Internet Protocol)

router. It routes the packets to N destinations from N sources. It has N calls to route.

Each of N tasks is allotted a time slice and is cyclically executed for routing packet from a source to its destination.

This is an example of round robin with time slicing scheduling.

Page 13: Round robin scheduling

ADVANTAGES OF ROUND ROBIN SCHEDULING

It is a simple scheduling algorithm and easy to implement in software.

Round robin scheduling is fair in the sense that every process gets an equal share of the CPU.

If we know the number of processes on the run queue, we can know the worst-case response time for a process.

Every process will be executed by CPU for fixed interval of time (which is set as Tslice ). So in this way no process left waiting for its turn to be executed by the CPU.

Page 14: Round robin scheduling

DISADVANTAGES OF ROUND ROBIN SCHEDULING

Sometimes 2 processes may have the same priority, but one of them might get suspended in the middle of execution, as it works on first come first serve basis.

If slicing time is too low, the processor output is reduced. More time is spent on context switching.

Page 15: Round robin scheduling

QUESTIONS?

Page 16: Round robin scheduling

SEMINAR BY:SIRIGAURI. NRAGHAV. S