View
19
Download
1
Category
Preview:
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
2
Schedule
• Real-Time System
• Synchronization
• Algorithm
• Bounding
• Experiments
• Conclusions
• Future work
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
3
Real-Time System
• Multiprocessor system
• Interconnection Network
• Shared memory
CPUCPU CPUCPU
CPUCPU CPUCPU
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
4
Real-Time System
• Cooperating Tasks
• Timing constraints
• Need synchronization– Shared Data Objects
• In this paper: Atomic Snapshot
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
??????
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
10
Snapshot
• Shared variables
• Read / Write registers
• Some values are related together
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
13
Linearizability
• Atomicity / Linearizability criteria
tWrite Write
Read
ci
tWrite Write
Read
ci
NO
NO
= returned by scanner
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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}}
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
26
Experiments• Scan operation - Average Response Time
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
27
Experiments• Update operation – Average Response Time
Håkan Sundell, phs@cs.chalmers.se
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
Håkan Sundell, phs@cs.chalmers.se
Chalmers University of Technology
29
Future work
• Investigations of other wait-free synchronization methods
• Implementations in RTOS kernels
Recommended