software transactional memory and conditional critical regions word-based systems
TRANSCRIPT
![Page 1: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/1.jpg)
Software Transactional Memory and Conditional Critical
Regions
Word-Based Systems
![Page 2: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/2.jpg)
Introduction: Motivation
Language Support for Lightweight Transactions (Harris & Fraser)
Implement a declarative style of concurrency control where programmers indicate desired safety properties
New syntax implements Hoare’s Conditional Critical Region
Implemented using their STM
CS 5204 – Fall, 2009
![Page 3: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/3.jpg)
CCR – Conditional Critical Region
CS 5204 – Fall, 2009
atomic (condition) { statements;}
1. Wait until Condition is satisfied2. Execute statements atomically
MeansMeans
public int get() { atomic (items != 0) { items --; return buffer[items]; }}
Pattern Example Use
![Page 4: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/4.jpg)
CCR Implementation
Built on top of Software Transactional Memory Uses all traditional STM commands and STMWait
CS 5204 – Fall, 2009
boolean done = false;while (!done) { STMStart (); try { if (condition) { statements; done = STMCommit (); } else { STMWait(); } } catch (Throwable t) { done = STMCommit (); if (done) { throw t; } }}
![Page 5: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/5.jpg)
STM Heap Structure
CS 5204 – Fall, 2009
.
.
.
Application Heap
.
.
.
.
A1: 7
A2: 100
A3: 200
A4: 500
A5: 600
.
.
.
Ownership Records
.
.
Version 1
Version 1
Version 1
Version 1
![Page 6: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/6.jpg)
STM - Simple Transaction
CS 5204 – Fall, 2009
boolean done = false;while (true) {
STMStart();readvalues;if(STMValidate()){ statements; done = STMCommit(); if(done) { break; }}
}
![Page 7: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/7.jpg)
Transaction Management
STMStart() STMAbort() STMCommit() STMValidate() STMWait()
CS 5204 – Fall, 2009
![Page 8: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/8.jpg)
STM - Simple Transaction
CS 5204 – Fall, 2009
.
.
.
Application Heap
.
.
.
.
A1: 7
A2: 100
A3: 200
A4: 500
A5: 600
.
.
.
Ownership Records
.
.
Transaction Descriptor 1 Active
A2: (100,7) -> (300,8)
A1: (7,15) -> (7,15)Version 15
Version 7
Version x
Version y
Transaction Descriptor 1 Committed
A2: 300Version 8
1
1
![Page 9: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/9.jpg)
STM Collisions - Abort
CS 5204 – Fall, 2009
.
.
.
Application Heap
.
.
.
.
A1: 7
A2: 100
A3: 200
A4: 500
A5: 600
.
.
.
Ownership Records
.
.
A2: (100,7) -> (300,8)
A1: (7,15) -> (7,15)
Version x
Version y
Transaction Descriptor 1 Active
A2: (100, 7) -> (9,8)
Transaction Descriptor 2 Active
2
1
1
Committing
A2’s Ownership Record is
unavailable! Commit Fails -
abort
A2’s Ownership Record is
unavailable! Commit Fails -
abort
Transaction Descriptor 2 Aborted
![Page 10: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/10.jpg)
STM Collisions - Sleep
CS 5204 – Fall, 2009
boolean done = false;while (!done) { STMStart (); try { if (condition) { statements; done = STMCommit (); } else { STMWait(); } } catch (Throwable t) { done = STMCommit (); if (done) { throw t; } }}
Abort and waitAbort and wait
But when do I wake up?
atomic (condition) { statements;}
![Page 11: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/11.jpg)
STM Sleep
CS 5204 – Fall, 2009
.
.
.
Application Heap
.
.
.
.
A1: 7
A2: 100
A3: 200
A4: 500
A5: 600
.
.
.
Ownership Records
.
.
A2: (100,7) -> (300,8)
A1: (7,15) -> (7,15)
Version x
Version y
Transaction Descriptor 1 Active
A1: (7,15) -> (7,15)
Committing
I failed my CCR condition, so I
aborted and fell asleep
I failed my CCR condition, so I
aborted and fell asleep
Transaction Descriptor 2 Asleep
Transaction Descriptor 1 Committed
Wake-upWake-up
![Page 12: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/12.jpg)
STM Stealing - Optimization
CS 5204 – Fall, 2009
.
.
.
Application Heap
.
.
.
.
A1: 7
A2: 100
A3: 200
A4: 500
A5: 600
.
.
.
Ownership Records
.
.
A2: (100,7) -> (300,8)
A1: (7,15) -> (7,15)
Version x
Version y
Transaction Descriptor 1 Committed
A2: (300,8) -> (300,9)
A3: (200, 8) -> (8,9)
Transaction Descriptor 2 Active
2
1
1
![Page 13: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/13.jpg)
STM – HTM Parallels: Data Copies
CS 5204 – Fall, 2009
Old DataHTM: XCOMMITSTM: Xaction Descriptor Entry
Original Memory
New DataHTM: XABORTSTM: Xaction Descriptor Entry
Copy Commit
![Page 14: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/14.jpg)
STM – HTM Parallels: 3 Tier Implementation
CS 5204 – Fall, 2009
HTM STM
![Page 15: Software Transactional Memory and Conditional Critical Regions Word-Based Systems](https://reader030.vdocuments.us/reader030/viewer/2022033023/56649c765503460f9492a6ea/html5/thumbnails/15.jpg)
Questions
CS 5204 – Fall, 2009
????????