Transactional Memory Introduction Prof R Guerraoui Distributed Programming
Transactional Memory (Introduction) Prof R. Guerraoui Distributed Programming Laboratory © R. Guerraoui 1
New York Times San Francisco, May 2004 Intel announced a move in the company’s strategy: adding more processors on a chip versus speeding up processors 2
Moore’s law? Clock speed flattening sharply The future is multi-core…every 6 months, you would have to exploit twice as much concurrency 3
and AMD is leading the industry to multi-core technology Sun’s multicore strategy centers around multithreaded software 4
It is easy to fork threads It is hard to take care of them 5
Locks Coarse-grained locks are inefficient and notreliable Fine-grained locks are error-prone Synchronized key-word in Java (50% of Java mistakes reported) 6
Example: double-ended queue Dequeue on one side and enqueue on the other; A big lock is a bad idea A small lock has to take care of proximity 7
/* * When a locked buffer is visible to the I/O layer * BH_Launder is set. This means before unlocking * we must clear BH_Launder, mb() on alpha and then * clear BH_Lock, so no reader can see BH_Launder set * on an unlocked buffer and then risk to deadlock. */ (Linux Kernel) 8
Wait-free data structures Require some skills : ))) We might imagine some libraries of wait-free data structures, if these are optimized Not for the masses 9
Transactions A transaction is a sequence of object operations Atomic Commit: take effect Abor: effect is discarded Appears to execute at an instance within its time interval 10
Public void Left. Enq(item x) { atomic { Qnode q = new Qnode(x); q. left = this. left; this. left. right = q; this. left = q; } } 11
Public item Left. Deq() { atomic { if (this. left == null) retry; … } } 12
Transactions write(1). O 1 - ok read(). O 2 - 25 p 1 read(1). O 1 - 1 write(). O 2 - 25 p 1 13
- Slides: 13