Docsity

Virtual-Time Round-Robin Scheduling: A Proportional-Share Algorithm for Operating Systems , Study Guides, Projects, Research of Operating Systems

Partial preview of the text

Download Virtual-Time Round-Robin Scheduling: A Proportional-Share Algorithm for Operating Systems and more Study Guides, Projects, Research Operating Systems in PDF only on Docsity!

usf CSCS

UNIVERSITY of SAN FRANCISCO department of computer science

Virtual-Time

Round-Robin

Scheduling

CS 326 Operating Systems Greg Benson

VTRR

VTRR: a proportional-share scheduler for

resources

Assign each client (thread/process) a share

Order clients in a queue by share value (highest

to lowest)

Schedule clients in a round-robin fashion, where

each client runs for Q quantum each time

selected.

Ensure higher-share processes consume more

Service Time Error

Due to quantization and OS overhead it is

impossible to achieve perfect fairness

We can denote the deviation from perfect

fairness as the service time error:

EA(t 1 , t 2 ) = WA(t 1 , t 2 ) − (t 2 − t 1 )

SA

i Si

Simple VTRR

Ensure clients are scheduled proportionally in a

single scheduling cycle, but not within a cycle

Schedule cycle : an iteration through all clients such

that proportional scheduling is achieved

Assign a initial counter equal to share for each

client

Order clients in a queue by decreasing share value

Cycle through queue, schedule client, decrement

counter and move to next client. Stop when all

Problems with Simple VTRR

Process may be unbalanced during a cycle, which

increases the service time error at any given point

in time.

A B C A B A A A A A

Simple approach cannot handle dynamic clients

Clients that enter in the middle of a cycle

Clients that leave during a cycle

E.g., creation, exiting, blocking, and unblocking

Static VTRR

First, deal with balancing clients within a cycle,

then add dynamic considerations

We need a way to determine when to give more

time to higher-share clients rather than walking

down the queue.

Basic idea: use virtual time and a virtual clock

Now, we can ask: if we schedule the next client,

will it receive more than it’s share within the cycle

so far?

VTRR Equations

Static VTRR works like Simple VTRR with two

additional checks:

(1) Time counter invariant: for any two

consecutive clients A and B, the counter value for

B must be no greater than A:

B.counter > A.counter

(2) VFT inequality:

If (1) holds, then schedule next client (B)

V F TC (t) − QV T (t + Q) <

Q

SC

Static VTRR Algorithm

Initialize queue, ordered by decreasing share

values

Schedule first client for Q time (assume Q = 1)

Update counter and VFT of first client and QVT

Look at next client in queue:

Check time counter invariant

Check VFT inequality

Updating VFT

For a new client A, set the VFT to:

For an existing clients that become runnable:

V F TA(t) = QV TA(t) +

Q

SA

V F TA(t) = MAX{QV TA(t) +

Q

SA

, V F TA(t ′ )}

Updating the Counter

We need to set the counter to something

reasonable it a client joins in the middle of a cycle

We will compute the counter value as a fraction

of the total remaining counts, where the fraction is

proportional to the client’s share:

The new counter value must be in between the

neighboring clients in queue

If a client is removed then inserted in the same

cycle, the new counter value is

CA =

SA

i Si

i Ci min(CA, Cold)

Project 1 VTRR

Three levels of VTRR support:

Simple VTRR

Static VTRR

Dynamic VTRR (extra credit)

You need to come up with tests!

No Floating Point in Kernel

Kernels do not support floating point for

efficiency

However, for more sophisticated scheduling

algorithms we want to compute with real

numbers

Solution: scale real numbers by a scale constant

See Pintos documentation

Class-based Implementation

Need to keep track of users in system

Need a new data structure for each ready user

The user struct will point to all active processes

with the same uid

Use proportional-share scheduling on user struct

instead of PCB or TCB

Schedule user processes using RR