290 likes | 396 Views
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
E N D
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 Interconnection Network Shared memory Real-Time System CPU CPU CPU CPU
Cooperating Tasks Timing constraints Need synchronization Shared Data Objects In this paper: Atomic Snapshot Real-Time System
Synchronization methods Lock Uses semaphores, spinning, disabling interrupts Negative Blocking Priority inversion Risk of deadlock Positive Execution time guarantees easy to do Synchronization Take lock ... do operation ... Release lock
Synchronization methods Lock-free Retries until not interfered by other operations Usually uses some kind of shared flag variable Synchronization Write flag with unique value ... do operation ... Check flag value and maybe retry
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 Synchronization
Synchronization methods Wait-free Uses atomic synchronization primitives Uses shared memory Negative Complex algorithms Memory consuming Synchronization Test&Set Compare &Swap Copying Helping Announcing Split operation ???
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 Synchronization
Shared variables Read / Write registers Some values are related together 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 Snapshot
Atomicity / Linearizability criteria Linearizability ci Write Write NO cj Write t Read YES ci Write Write t Read YES ci Write Write t = returned by scanner
Atomicity / Linearizability criteria Linearizability Read NO ci Write Write t Read NO ci Write Write t = returned by scanner
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 ti Write tj Read tk Write ser t Linearizability
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 Algorithm
Unbounded Snapshot Protocol Algorithm Snapshotindex ? = previous values / nil w = writer position c1 v ? ? ? ? w nil nil ci v ? ? ? ? w nil nil cc v ? ? ? ? w nil nil t
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 Bounding
Solution in real-time systems Using timing information! Bounding int TestAndSet(int *p) atomic { if(!*p) {*p=1;return 1} else {return 0} }
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 Bounding
Use cyclical buffers Keep track that updater position is always behind the scanner so that new positions are always free Bounding
Needed buffer length is dependent on how fast the updaters is compared to the scanner Each component can have different buffer lengths Bounding
Needed buffer length for component k Can be refined even further Bounding where Ts is the period for the snapshot task Tw is the period for the writer tasks
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 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 Experiments
7 different scenarios Experiments
Scan operation - Average Response Time Experiments
Update operation – Average Response Time Experiments
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 Conclusions
Investigations of other wait-free synchronization methods Implementations in RTOS kernels Future work