190 likes | 318 Views
Transaction Synchronizers. Virendra J Marathe Victor Luchangco Sun Microsystems Labs Sun Microsystems Labs & Univ. of Rochester. October 16 th , 2005. Transactional Memory (TM). Locks are hard to program with TM simplifies concurrent programming Transactions
E N D
Transaction Synchronizers Virendra J MaratheVictor Luchangco Sun Microsystems Labs Sun Microsystems Labs & Univ. of Rochester October 16th, 2005
Transactional Memory (TM) • Locks are hard to program with • TM simplifies concurrent programming • Transactions • Atomicallyexecuted sequence of instructions • Txns areisolated: Do not see each other • Isolation and atomicity simplify concurrent programming
Limitations: Concurrency • Travel Booking • Reserve air ticket • Reserve hotel room • Reserve rental car • Requirement: Booking happens atomically • Txns must do these independent ops sequentially
Limitations: Condition Synchronization Exchange Channel • A meeting place for independent threads • Threads exchange private data over the channel • Can txns use the channel? • No, need to break isolation
A Way Out: Transaction Synchronizers • Relax Isolation in a restricted fashion • Use a transaction interaction hub, thesynchronizer • A transactionsynchronizesat a synchronizer • Data encapsulated within synchronizers • Access to this data can be non-transactional
A Way Out: Transaction Synchronizers • Synchronized txns fate is bound • Commit or Abort together • Transitive closure of synchronized txns is thecohortset S1 S2 Synchronizers T1 T2 T3 Cohort Collaborators
DSTM-based Synchronizers • We propose an extension to DSTM [HLMS03] • DSTM: An STM that supports dynamic sized data structures • DSTM txn states: ACTIVE, ABORTED, or COMMITTED • Txn Synchronizer called to TMSynchronizer (is similar to DSTM’s TMObject)
The TMSynchronizer • TMSynchronizer Interface: synchronize( )method • Atomically binds caller to other txns synchronized on that TMSynchronizer • Returns the encapsulated data object
Mechanism Overview • Commit Protocol: Txn declares its commit intention • A newCOMMITTINGstate for txns • Txn waits for its cohort txns • Commit-synchronize race • SealTMSynchronizer’s current version when all collaborators are in COMMITTING state • Conflict Handling • Conflicts with COMMITTING txns handled differently S1 S1 S2 S2 old T1 T2 T3 S1 new T4
Solution: Travel Booking S = new TMSynchronizer( new TravelPlan( ) ) TravelPlan { spawn air ticket booking T1 tocket_flag; spawn hotel room booking T2 room_flag; spawn rental car booking T3 car_flag; } T1 T2 T3 book a ticket book a room rent a car tp = S.synchronize( ) set tp.ticket_flag set tp.room_flag set tp.car_flag wait on other flags all commit( )
Solution: Exchanger S = new TMSynchronizer( new Exchanger( )) Exchanger { // txn1 and txn2 are interested Data d1; // in exchanging data items B1 and B2 Data d2; // respectively } T1 T2 local computation local computation ex = S.synchronize( ) exchange: if(CAS ex.d1 to B1) if(CAS ex.d1 to B2) wait for ex.d2 wait for ex.d2 else else if(CAS ex.d2 to B1) if(CAS ex.d2 to B2) wait for ex.d1 wait for ex.d1 else else goto exchange goto exchange local computation local computation T1 and T2 commit( ) What if T3 also wants to exchange data, and binds to T1 and T2 before they commit? Need an unsynchronize( ) method to pull out T3?
Extensions • unsynchronize( ) • register( ) and unregister( ) • Issue: Expose synchronized txns to unsynchronized txns
Conclusion and Future Work • Txn Synchronizers: Way to relax isolation to enable txn interaction • Permits concurrency within atomic blocks • Extend Synchronizer semantics to support condition synchronization • Synergy with Txn Nesting?
Special Thanks to • The Scalable Synchronization Research Group, Sun Microsystems Labs • Especially to Mark Moir for reviewing a preliminary draft of the paper
The TMSynchronizer • TMSynchronizer interface: synchronize( )method • Atomically inserts a txn at the c-list head Txn 1 Txn 2 c-list Old Version Old Data Object Start New Version TMSynchronizer s-locator New Data Object
An example commit S-locator c-list Old Version New Version Start TMSynchronizer Old Data Object New Data Object CAS Seal Txn 1 COMMITTING Txn 1 COMMITTED Txn 2 COMMITTING Txn 2 COMMITTED Collaborators
Synchronize on a Sealed TMSynchronizer S-locator c-list Old Version New Version Start CAS TMSynchronizer Copy Old Data Object New Data Object Seal New Data Object Private S-locator c-list Old Version New Version Txn 1 ACTIVE
DSTM Implementation Transaction Descriptor Status: COMMITTED Transaction Old Version Old Data Object Start New Version CAS Locator TMObject1 New Data Object Copy Transaction Descriptor Status: ACTIVE Transaction Descriptor Status: COMMITTED Transaction Old Version New Version New Transaction Private Locator Locator New Data Object