cs 204: schedulingjiasi/teaching/cs204_spring17/slides/lec3_scheduling.pdfimplementation...

Post on 30-May-2020

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS204:Scheduling

Jiasi ChenLectures:MWF12:10-1pm

HumanitiesandSocialSciences1403

http://www.cs.ucr.edu/~jiasi/teaching/cs204_spring17/

1

Overview

• Whatisscheduling?• Roundrobin• Weightedroundrobin

• Generalizedprocessorsharing(GPS)• ImplementationsofGPS

• Deficitroundrobin• Weightedfairqueuing

• RatecontrolwithGPS:Tokenbucket

2

Q:Howshouldacommonresourcebe

sharedbetweenmultipleusers?

Whatisscheduling?

• Sendpacketsfrommultiplehosts• Requiredfeatures

• Fair• Easytoimplement• Scalable• Work-conserving

• Desirablefeatures• Admissioncontrol• QoS fordifferenttypesoftraffic

3

H1

H2

H3

Whosedatagetstransmitted?

WhatisNOTscheduling?

4

H1

H2

H3

centralizedscheduling

randomaccess

Uplink?Downlink?

Toyexample

5

SenderA:5-bitpackets

SenderC:2-bitpackets

SenderB:7-bitpackets

Totalbandwidth=12bits/s

Fairness

• Onemeasureoffairness:max-minfair• Maximizetheminimumrateacrossallusers

6

SenderA:5-bitpackets

SenderC:2-bitpackets

SenderB:7-bitpackets

5

5

2

4

6

2

Max-minfair NOTmax-minfair

HowtoCalculateMax-MinFairness?

1. Computethefairshareofeachunsatisfiedflow2. Assignthefairsharetoeachunsatisfiedflow3. Takebackanyover-assignments,andrepeatfromStep1

7

Totalbandwidth=12bits/s 1.12bits/3users=4bits/user2.Assign4 4 43.Takeback2à 4 4 21.2bits/2remainingusers=1bit/user2.Assign5 5 2

Roundrobin

• Choose1packetfromeachsubqueue

8

Afteroneround570

Aftertworounds1052

Isthismax-minfair?(5,5,2)

Weightedroundrobin

• Choosecertain#packetsfromeachsubqueue• #ofpacketssent=weight/packetsize

9

5

5

2

Weights5/5=1packet

5/7packet

2/2=1packet

#packets7packets*5bits/packet=35bits

5packets*7bits/packet=35bits

7packets*2bits/packet=14bits

Numberofbitssent7packets

5packets

7packets

#packets(normalized*7)

Isthismax-minfair?(5,5,2)Needtoknowpacketsize!

Overview

• Whatisscheduling?• Roundrobin• Weightedroundrobin

• Generalizedprocessorsharing(GPS)• ImplementationsofGPS

• Deficitroundrobin• Weightedfairqueuing

• RatecontrolwithGPS:Leakybucket

10

Q:Howshouldacommonresourcebe

sharedbetweenmultipleusers?

Bit-by-bitRoundRobin

• Willschedulingonafinergranularitydothetrick?

11

Afteroneround552

Aftertworounds10104

Isthismax-minfair?(5,5,2)√Isthisimplementable?

Generalizedprocessorsharing

• Sendinfinitesimalamountofbitseachround• Idealizedversionofbit-by-bitroundrobin• Notimplementable,butachievesperfectfairness

12

2/12

5/125/12

Howtoimplementthis?

Overview

• Whatisscheduling?• FIFO• Roundrobin• Weightedroundrobin

• Generalizedprocessorsharing(GPS)• ImplementationsofGPS

• Deficitroundrobin• Weightedfairqueuing

• RatecontrolwithGPS:Leakybucket

13

Q:Howshouldacommonresourcebe

sharedbetweenmultipleusers?

• SeewhichpacketswouldfinishfirstunderGPS

• Sendpacketsinthatorder

Weightedfairqueuing

14

timeP1,P1P1P2 P2,P2P3,P3

Afteroneround552

Aftertworounds10104

O(log(n))complexityWhy?

• Problem:whatifnewuserentersthesystem?

Weightedfairqueuing(2)

15time

P1,P1P1P2P1,P2

P1 P1,P1P2

timeP2,P2P3,P3

P3P2,

Finishingtimesaredifferent,needtobeupdated!

• Solution:use“virtualtime”=#ofbit-by-bitroundrobinrounds

Weightedfairqueuing(3)

16

P1 =5P1 =2P1=7P2=10P2 =6

P1 P1,P1P2

timeP2,P2P3,P3

GPS:

virtualtime1

Bit-by-bitRR:

2345678910

• Let’scalculatethevirtualfinishingtimewiththenewuser

Weightedfairqueuing(4)

17

virtualtime

P1 =5P1 =2P1=7P2=10P2 =6

P1 P1,P1time

P2P3 P1,P2P3 P2,

GPS:

Bit-by-bitRR:

1234567891011

Weightedfairqueuing(5)

18

P1 =5P1 =2P1=7P2=10P2 =6

• Evenifnewuserjoins,the“virtualtime”staysthesame

virtualtime1110987654321

Bit-by-bitRR:

virtualtime10987654321

Bit-by-bitRR: P1 =5P1 =2P1=7P2=10P2 =6

Thevirtualfinishingtimesstayedthesame!

Note:BBRRvirtualtimeisshownhereforeaseofexposition;WFQvirtualtimeisslightlydifferent.SeeParekh-Gallager fordetails.

Deficitroundrobin

• Thatseemsconfusing…isthereasimplerway?

19

Q =5

Q =5

Q =2

• DefineaquantumQforeachqueue• Canonlysendifhaveenough“credits”inQ• Otherwise,save“credits”fornextiteration

Deficitroundrobin

20

Afteroneround502

Aftertworounds874

Q =5

Q =5

Q =2

O(1),butlessaccurate

Q =5SendQ =0

Q =5CannotsendQ =5

Q =2SendQ =0

Q =5+5=10SendQ =3

Q =2SendQ =0

Q =5SendQ =0

Isthismax-minfair?(5,5,2)

Overview

• Whatisscheduling?• FIFO• Roundrobin• Weightedroundrobin

• Generalizedprocessorsharing(GPS)• ImplementationsofGPS

• Deficitroundrobin• Weightedfairqueuing

• RatecontrolwithGPS:Tokenbucket

21

Q:Howshouldacommonresourcebe

sharedbetweenmultipleusers?

PerformanceguaranteeswithGPS

• GPSimplementationsgiveusanaveragethroughput

• Whataboutdelayguarantee?

22

e.g.,w1 =5,w2 =5,w3 =2Rateofuserk

TokenBucket

• Packetmetrics• Burst:howmanypacketsaresentallatonce• Peakrate:howmanypacketsaresentoverashortperiodoftime

• Averagerate:howmanypacketsaresentoveralongperiodoftime

• HowmanypacketsaresentthroughthenetworkintimeintervalT?• akT +Bk

23

Tokensarrivewithrateak

BucketcanholdBk tokens

Packetscanonlyleaveifaccompaniedbyatoken

GPS+TokenBucket

• Assumeρk >ak.Thenmaxdelayexperiencedbyabit:

• Why?1. AtmostBk packetswaitinginGPS

scheduler2. Delay=(Bk pkts)/(ρk pkts/s)

24

GPSscheduler

Kleakybuckets

GPSbandwidth

Tokenbucketsize

Implementation

• DifferentschedulingschemesavailableinLinux

25

Implementation

• tc trafficcontroltool

26

jc@jc-ideapad500s:~$ tc qdisc show dev wlp2s0qdisc mq 0: root qdisc pfifo_fast 0: parent :1 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1qdisc pfifo_fast 0: parent :2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1qdisc pfifo_fast 0: parent :3 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1qdisc pfifo_fast 0: parent :4 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Addtokenbucket

jc@jc-ideapad500s:~$ tc class show dev wlp2s0class htb 1:10 parent 1:1 prio 0 rate 1Mbit ceil 1Mbit burst 1600b cburst 1600class htb 1:1 root rate 1Mbit ceil 1Mbit burst 1600b cburst 1600b

Sources

• AnIntroductiontoComputerNetworks,PeterDordalhttp://intronetworks.cs.luc.edu/current/html/queuing.html

• A.ParekhandR.Gallager,“AGeneralizedProcessorSharingApproachtoFlowControlinIntegratedServicesNetworks:TheSingle-NodeCase”,ToN 1993.

27

top related