31
Company LOGO Lock-free and Wait- free Slot Scheduling Algorithms Pooja Aggarwal Smruti R. Sarangi Computer Science, IIT Delhi, India 1

Lock-free and Wait-free Slot Scheduling Algorithms

  • Upload
    morey

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

Pooja Aggarwal Smruti R. Sarangi Computer Science, IIT Delhi, India. Lock-free and Wait-free Slot Scheduling Algorithms. Outline. Motivation Related Work Parallel Slot Scheduler Design Performance Results Summary. Real-Time System . How to schedule the requests. Thread i. - PowerPoint PPT Presentation

Citation preview

Page 1: Lock-free and Wait-free Slot Scheduling Algorithms

1

Company

LOGO

Lock-free and Wait-free Slot Scheduling

AlgorithmsPooja Aggarwal Smruti R. SarangiComputer Science, IIT Delhi, India

Page 2: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

2

Outline

Motivation

Related Work

Parallel Slot Scheduler Design

Performance Results

Summary

Page 3: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

3time

Thread i Thread jHow to schedule

the requests

Real-Time System

t1 t2ti

Page 4: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

4

Slot Scheduling

Treats time as a discrete quantity

Globally-visible reservation system

Requires advance algorithm for parallel scheduling

Page 5: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

5

T0 T1 T2 Tn-2 Tn-1 Tn

T1

T1

T1 T2

T2

time

Shared Resource

Reservation System

Page 6: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

6

Related Work In 1982 Ousterhout proposed the matrix representation

of time-slices and processors to facilitate running jobs simultaneously

The real-time scheduler for the Rialto operating system, based on CPU reservations, bears a great deal of similarity to slot scheduling.

Generic scheduling using locks In 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

Page 7: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

7

Nx1 Problem

N

M

FREE

BUSY

Page 8: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

8

NxM

Nx1 Problem

N

M

Page 9: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

9

Time Slots

P3

1xM Problem

T0 T1 T2 T3 T4 Ti Ti+1 Ti+2

P2 P2 P2 P3 P3 P3

Resource can process one

request per slot

Page 10: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

10

2 2

busy Free

Empty slot

2 4 4

2

time

NxM Problem

Page 11: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

11

Problems with Locking

× Deadlock – no progress× Priority Inversion – lower-priority process

preempted while holding lock× Convoying – lockholder de-scheduled× Starvation – a process never completes

Page 12: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

12

Lock-free Algorithm

Optimistic approacha lock-free algorithm can run in four phases:

complete one's own operation assist an obstructing operation (internal helping) abort an obstructing operation and wait

Fast execution when low contention Avoids blocking and priority inversionAvoids deadlock

Page 13: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

13

Wait-free Algorithm

Per-operation progress guaranteesEvery operation is guaranteed to complete

in a finite number of stepsFaster thread helps the slower threadWait-free = Lock-free + Starvation free

Page 14: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

14

Basic 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 slots

First chooses a monotonically increasing request ID (reqid)

Announce the request helps all threads with a non-

larger reqidREQUEST 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 HELPAnnouncing the request

Page 15: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

15

Optimized Helping Criteria Drawback of basic scheme:

Helping even if no starvation even when there is no contention

many threads help same operations large redundant work

Optimization: REQUEST_THRESHOLD HELP_THRESHOLD INTERNAL HELPING

Page 16: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

16

Parallel Slot Scheduler Design Schedule operation is accomplished in 3 three atomic steps

1. Announce the request concurrent processes realize that there is an operation-in-

progress

2. Temporary Reservation Try to reserve the earliest possible available slots

3. Permanent Reservation finalizing the reserve slots

Page 17: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

17

FSM 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

Page 18: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

18

Schedule 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

Page 19: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

19

State Transitions’ of a Slot

Tstamp reqId tid state slotno round

EMPTY

SOFT

HARD

Temporary Reservation

Permanent Reservation

threadId

Page 20: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

20

Role of Saving Slot

4 4 4 4

2

1 1

2

Already booked

Temporary Reservation

Reserved 4

slots

Reserved 2 slots

Page 21: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

21

Role of Round

1 1 1

2 2

NEWSOFTCANCEL

2 2

NEWSOFTCANCELNEW

2

SOFT

round is 1round is 2Round is 3

With every cancellation, round

is incrementCAS

Page 22: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

22

Selecting a Slot

4 4 4 4

6 6

1

2 2

1 1

1

BOOKED

FREE

SOFT, 2SOFT, 4Another helper reserved slot

1 1

1

1Another helper Booked the slot

5

7

SOFT,2

Page 23: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

23

Page 24: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

24

Issues and Resolutions ABA issue

Time-Stamp

Multiple rollbacks CANCEL-THRESHOLD

Multiple reservations PATH array SHADOW array

Page 25: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

25

Setup

Two six core 2.66 Ghz Intel Xeon GHz processors

Architecture

Ubuntu Linux 12.10 OS

64 GBRAM

24Threads

Sun’s Java SE Runtime 1.6.0Platform

Page 26: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

26

Workload

The inter-request distances are truncated normal distributions Box-Muller transform is used to generate the

normal variants Experiment is executed till one of the

thread completes all its iterations Each thread performs 1000 iterations Each experiment is performed 10 times,

and mean values are reported

Page 27: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

27

Mean time per request (treq)

Lock is 100 times slower

Page 28: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

28

Work Done

• We run the system till the fastest thread completes κ requests.

• wk = tot requests/(κ ×NUMTHREADS).

Wait-free Work done is around 10 % more

Page 29: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

29

Sensitivity: Request-threshold

Page 30: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

30

Summary First lock-free and wait-free algorithm for four

variants of the generic slot scheduling problem

Lock-free is fastest of the three approaches

Wait-freedom incurs an inherent trade-off bounds the completion time of a single operation Total Work done is more

All our algorithms are linearizable Proposed design scheme might be applicable for

other wait-free data structures

Page 31: Lock-free and Wait-free Slot Scheduling Algorithms

Company

LOGO

31

Thank you!Questions?