29
Håkan Sundell, [email protected] Chalmers University of Technology 1 Simple and Fast Wait-Free Snapshots for Real-Time Systems Håkan Sundell Philippas Tsigas Yi Zhang Computing Science Chalmers University of Technology

Simple and Fast Wait-Free Snapshots for Real-Time Systems

Embed Size (px)

DESCRIPTION

Simple and Fast Wait-Free Snapshots for Real-Time Systems. Håkan Sundell Philippas Tsigas Yi Zhang Computing Science Chalmers University of Technology. Real-Time System Synchronization Algorithm Bounding Experiments Conclusions Future work. Schedule. Multiprocessor system - PowerPoint PPT Presentation

Citation preview

Page 1: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

1

Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell

Philippas Tsigas

Yi Zhang

Computing Science

Chalmers University of Technology

Page 2: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

2

Schedule

• Real-Time System

• Synchronization

• Algorithm

• Bounding

• Experiments

• Conclusions

• Future work

Page 3: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

3

Real-Time System

• Multiprocessor system

• Interconnection Network

• Shared memory

CPUCPU CPUCPU

CPUCPU CPUCPU

Page 4: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

4

Real-Time System

• Cooperating Tasks

• Timing constraints

• Need synchronization– Shared Data Objects

• In this paper: Atomic Snapshot

Page 5: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

5

Synchronization

• Synchronization methods– Lock

• Uses semaphores, spinning, disabling interrupts

• Negative– Blocking

– Priority inversion

– Risk of deadlock

• Positive– Execution time guarantees easy to do

Take lockTake lock

... do operation ...... do operation ...

Release lockRelease lock

Page 6: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

6

Synchronization

• Synchronization methods– Lock-free

• Retries until not interfered by other operations

• Usually uses some kind of shared flag variable

Write flag with unique valueWrite flag with unique value

... do operation ...... do operation ...

Check flag value and maybe retryCheck flag value and maybe retry

Page 7: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

7

Synchronization

• Synchronization methods– Lock-free

• Negative– No execution time guarantees, can continue forever - thus

can cause starvation

• Positive– Avoids blocking and priority inversion

– Avoids deadlock

– Fast execution when low contention

Page 8: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

8

Synchronization

• Synchronization methods– Wait-free

• Uses atomic synchronization primitives

• Uses shared memory

• Negative– Complex algorithms

– Memory consuming

Test&SetTest&Set

CompareCompare&Swap&Swap

CopyingCopying

HelpingHelping

AnnouncingAnnouncing

SplitSplitoperationoperation

??????

Page 9: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

9

Synchronization

• Synchronization methods– Wait-free

• Positive– Execution time guarantees

– Fast execution

– Avoids blocking and priority inversion

– Avoids deadlock

– Avoids starvation

– Same implementation on both single- and multiprocessor systems

Page 10: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

10

Snapshot

• Shared variables

• Read / Write registers

• Some values are related together

Page 11: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

11

Snapshot

• Snapshot– A consistent momentous state of a set of several

shared variables– One reader

• Reads the whole set of variables in one atomic step

– Many writers• Writes to only one variable each time

Page 12: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

12

Linearizability

• Atomicity / Linearizability criteria

Write Write

Write

ci

cj tNO

t

t

Write Write

Read

Write Write

Read

YES

YES

ci

ci

= returned by scanner

Page 13: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

13

Linearizability

• Atomicity / Linearizability criteria

tWrite Write

Read

ci

tWrite Write

Read

ci

NO

NO

= returned by scanner

Page 14: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

14

Linearizability

• If all of those criteria are fulfilled then our snapshot algorithm are linearizable

• All operations can be transformed into a serial sequence of atomic operations

t

Read

Write

Writeti

tj

tk

ser

Page 15: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

15

Algorithm

• Wait-Free Snapshot Algorithm– Unbounded memory– Each component represented by an infinite nil-

value-initialized array, higher index for more recent values

– A global index register where all component writers writes the updated value

– The reader scans all component arrays backwards from current position

Page 16: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

16

Algorithm

• Unbounded Snapshot Protocol

tv ? ? ? ? w nil nil

v ? ? ? ? w nil nil

v ? ? ? ? w nil nilc1

ci

cc

Snapshotindex ? = previous values / nilw = writer position

Page 17: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

17

Bounding

• We must recycle the array indexes in some way

• Keep track of the scanner versus the updaters positions

• Previous solution by Ermedahl et. al– Synchronized using atomic Test and Set

operations

Page 18: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

18

Bounding

• Solution in real-time systems– Using timing information!

int TestAndSet(int *p)atomic { if(!*p) {*p=1;return 1} else {return 0}}

Page 19: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

19

Bounding

• Assuming system with periodic fixed-priority scheduling

• Notations from Standard Real-Time Response Time Analysis

• Use information about– Periods , T– Computation time , C– Response times , R

)(ihpjj

j

iii C

T

RCR

Page 20: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

20

Bounding

• Use cyclical buffers

• Keep track that updater position is always behind the scanner so that new positions are always free

Page 21: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

21

Bounding• Needed buffer length is dependent on how

fast the updaters is compared to the scanner

• Each component can have different buffer lengths

Page 22: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

22

Bounding

• Needed buffer length for component k

• Can be refined even further

2max*2 )(

S

Wkwrik T

Tl i

where Ts is the period for the snapshot taskTw is the period for the writer tasks

Page 23: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

23

Experiments

• Using a Sun Enterprise 10000 multiprocessor computer

• 1 scanner task and 10 updater tasks, one on each cpu

• Comparing two wait-free snapshot algorithms– Using timing information– Using test and set synchronization

Page 24: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

24

Experiments

• Measuring response time for scan versus update operations

• All updaters have the same period• All 10 components have the same buffer

lengths for the algorithm using timing information

• The algorithm using test and set synchronization uses a buffer of length 3

Page 25: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

25

Experiments

• 7 different scenarios

Scenario Scan Period (us)

Update Period (us)

Buffer Length

1 500 50 3

2 200 50 3

3 100 50 3

4 50 50 4

5 50 100 6

6 50 200 10

7 50 500 22

Page 26: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

26

Experiments• Scan operation - Average Response Time

Page 27: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

27

Experiments• Update operation – Average Response Time

Page 28: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

28

Conclusions• Update operation

– Using timing information gives up to 400 % better performance

• Scan operation– Using timing information gives up to 20 % better

performance in common practical scenarios

• Update operation is much more frequent than Scan– Timing information can improve the performance

significantly

• Simpler algorithm

Page 29: Simple and Fast Wait-Free Snapshots for Real-Time Systems

Håkan Sundell, [email protected]

Chalmers University of Technology

29

Future work

• Investigations of other wait-free synchronization methods

• Implementations in RTOS kernels