Pooja Aggarwal Smruti R Sarangi Computer Science IIT Delhi India 1 Outline Motivation Related Work Parallel Slot Scheduler Design Performance Results Summary 2 time Thread ID: 140167
Download Presentation The PPT/PDF document "Lock-free and Wait-free Slot Scheduling ..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Lock-free and Wait-free Slot Scheduling Algorithms
Pooja Aggarwal
Smruti R. SarangiComputer Science, IIT Delhi, India
1Slide2Outline
Motivation Related WorkParallel Slot
Scheduler DesignPerformance Results
Summary2Slide3
time
Thread
i
Thread
j
How to schedule the requests
Real-Time System
t
1
t
2
t
i
3Slide4
Slot SchedulingTreats time as a discrete quantityGlobally-visible reservation system
Requires advance algorithm for parallel scheduling
4Slide5
T
0
T
1
T
2
T
n-2
T
n-1
T
n
T
1
T
1
T
1
T
2
T
2
time
Shared Resource
Reservation System
5Slide6Related Work
In 1982 Ousterhout proposed the matrix representation of time-slices
and processors to facilitate running jobs simultaneouslyThe real-time scheduler
for the Rialto operating system, based on CPU reservations, bears a great deal of similarity to slot scheduling. Generic scheduling using locksIn 2009 Mhamdi et. al. gave online variants of scheduling problem for a message passing based
system
In
2011 Keller et. al. propose an
offline version
of the algorithm that has a known task
dependence graph
.
We propose a novel, parallel, and
Linearizable non-blocking slot scheduling algorithms
6Slide7
Nx1 Problem
N
M
FREE
BUSY
7Slide8
NxM
Nx1 Problem
N
M
8Slide9
Time Slots
P3
1xM Problem
T
0
T
1
T
2
T
3
T
4
T
i
T
i+1
T
i+2
P2
P2
P2
P3
P3
P3
9
Resource can process one request per slotSlide10
2
2
busy Free
Empty slot
2
4
4
2
time
NxM
Problem
10Slide11
Problems with LockingDeadlock – no progress
Priority
Inversion – lower-priority process preempted while holding lockConvoying – lockholder de-scheduledStarvation – a process never completes
11Slide12Lock-free
AlgorithmOptimistic approach
a lock-free algorithm can run in four phases: complete
one's own operationassist an obstructing operation (internal helping)abort an obstructing operationand waitFast execution when low contention
Avoids
blocking and priority
inversion
Avoids
deadlock
12Slide13Wait-free Algorithm
Per-operation progress guarantees
Every operation is guaranteed to complete in a finite number of
stepsFaster thread helps the slower threadWait-free = Lock-free + Starvation free
13Slide14Basic Helping Mechanism
Each thread is assigned a priority based on the initial timestamp of its request Shared
Data Structure is used to store the requests
Each thread requesting for slotsFirst chooses a monotonically increasing request ID (reqid)Announce the requesthelps all threads with a non-larger reqid
REQUEST
entry
per thread
requestId
state
path
threadId
timeSlot
numSlots
9
SOFT
null
1
3
4
10
NEW
null
2
10
4
11
NEW
null
3
7
4
NEED TO HELP
Announcing the request
14Slide15Optimized
Helping CriteriaDrawback of basic scheme:Helping even if no starvation
even when there is no contentionmany threads help same operations
large redundant workOptimization:REQUEST_THRESHOLDHELP_THRESHOLDINTERNAL HELPING
15Slide16
Parallel Slot Scheduler Design Schedule operation is accomplished in 3 three atomic steps
Announce the request
concurrent processes realize that there is an operation-in-progressTemporary ReservationTry to reserve the earliest possible available slotsPermanent Reservationfinalizing the reserve slots
16Slide17FSM of a
Request
NEW
SOFT
FORCEHARD
DONE
CANCEL
FAIL
Make temporary reservation
Finished reserving the required slots
Make permanent reservation
POINT
of LINEARIZABILITY
POINT of LINEARIZABILITY
Cancelled by other thread or cancelled itself
Could not find empty slot
17Slide18Schedule Operation
requestId
state
path
threadId
timeSlot
numSlots
EMPTY
SOFT
9
NEW
null
1
3
4
1
1
1
SOFT
HARD
(3,1)
(3,1),(4,2),(5,2)
1
(3,1),(4,2),(5,2),(6,5)
FORCEHARD
POINT
of LINEARIZABILITY
1
1
1
1
DONE
10
NEW
null
6
4
3
6 6
SOFT
(4,1),(5,1)
CANCEL
NEW
null
6 6 6
SOFT
(7,5),(8,5),(9,5)
FORCEHARD
6 6 6
DONE
18Slide19
State Transitions’ of a Slot
Tstamp
reqId
tid
state
slotno
round
EMPTY
SOFT
HARD
Temporary Reservation
Permanent Reservation
threadId
19Slide20
20
Role of Saving Slot
4 4 4 4
2
1 1
2
Already booked
Temporary Reservation
Reserved 4 slots
Reserved 2 slotsSlide21
21
Role of Round
1 1 1
2 2
NEW
SOFT
CANCEL
2 2
NEW
SOFT
CANCEL
NEW
2
SOFT
round is 1
round is 2
Round is 3
With every cancellation, round is increment
CASSlide22
22
Selecting a Slot
4 4 4 4
6 6
1
2 2
1
1
1
BOOKED
FREE
SOFT, 2
SOFT, 4
Another
helper reserved slot
1
1
1
1
Another helper
Booked the slot
5
7
SOFT,2Slide23
23Slide24Issues and Resolutions
ABA issue Time-Stamp
M
ultiple rollbacksCANCEL-THRESHOLDMultiple reservationsPATH arraySHADOW array
24Slide25
Setup
25Slide26Workload
The inter-request distances are truncated normal distributions
Box-Muller
transform is used to generate the normal variantsExperiment is executed till one of the thread completes all its iterationsEach thread performs 1000 iterationsEach experiment is performed 10 times, and mean values are reported
26Slide27Mean time per request (
treq)
27
Lock is 100 times slowerSlide28Work Done
We run the system till the fastest thread completes κ requests
.
wk = tot requests/(κ ×NUMTHREADS).
28
Wait-free Work done is around 10 % moreSlide29
Sensitivity: Request-threshold
29Slide30Summary
First lock-free and wait-free algorithm for four variants of the generic slot scheduling problemLock-free is fastest of the three approaches
Wait-freedom incurs an inherent trade-offbounds the completion time of a single operation
Total Work done is moreAll our algorithms are linearizableProposed design scheme might be applicable for other wait-free data structures30Slide31
Thank you!Questions?
31