Advanced Topic 50 of 51 Concurrency & Parallelism
Hardware Transactional Memory
CPU support for optimistic atomic regions.
How it works
Hardware transactional memory lets the processor execute a region of code speculatively as an atomic transaction: reads and writes are tracked in the cache, and if no conflicting access from another core occurs, the transaction commits all changes at once; otherwise it aborts and rolls back. Intel TSX offered restricted transactional memory with xbegin and xend and hardware lock elision, IBM POWER and Z have versions, and ARM defined TME. A fallback path using a lock is required because transactions can always abort.
Where it is used
Elision of coarse locks to run critical sections concurrently when they do not conflict, speeding up concurrent data structures and databases, was the main use.
Common pitfall
Transactions abort for capacity overflow of the cache, interrupts, system calls and conflicts, so they only work for small, short regions. Security issues led Intel to disable TSX on many processors. Performance can be unpredictable and fallback paths must be correct. Support is limited and inconsistent across vendors, so it is rarely relied on in portable software.
Where it fits in the course
Hardware Transactional Memory is topic 50 of 51 in Concurrency & Parallelism, rated Advanced. It follows Memory Models in Languages. The next topic is Performance Scaling Analysis.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Concurrency & Parallelism quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Concurrency & Parallelism quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Hardware Transactional Memory?
Where do people use Hardware Transactional Memory?
What is the most common mistake with Hardware Transactional Memory?
What should I learn before this topic?
How can I practice it?
Is Hardware Transactional Memory hard to learn?
How long does it take to learn Hardware Transactional Memory?
Which topics are related to Hardware Transactional Memory?
What should I study after Hardware Transactional Memory?
Related topics
- Memory Models in Languages (Concurrency & Parallelism)
- Performance Scaling Analysis (Concurrency & Parallelism)
- Linearizability (Concurrency & Parallelism)
- Backpressure (Concurrency & Parallelism)
- Virtual Memory in Hardware (Computer Architecture & Logic)
- Manual Memory Management (Languages & Compilers)
- Finite State Machines in Hardware (Computer Architecture & Logic)