Download presentation
Presentation is loading. Please wait.
Published byChristina Rose Modified over 9 years ago
1
2007-03-16 1 The ATOMOS Transactional Programming Language Mehdi Amirijoo Linköpings universitet
2
2007-03-16 Mehdi Amirijoo2 Background Transactional memory Conditional waiting Transaction Nesting Evaluation Conclusion
3
2007-03-16 Mehdi Amirijoo3 Background Multi-threaded application Access to shared data using locks semaphore s;... wait(s); //decrease s count++; signal(s); //increase s...
4
2007-03-16 Mehdi Amirijoo4 Background Course-grained locking leads to serialization on high-contention data structures Process P1 { wait(s);... d.a++;... signal(s); } Process P2 { wait(s);... d.b++;... signal(s); } Process P3 { wait(s);... d.a++;... signal(s); }
5
2007-03-16 Mehdi Amirijoo5 Background Fine-grained locking: improves concurrency increases code complexity (deadlocks) degrading performance Process P1 {... wait(s1); d.a++; signal(s1);... } Process P2 {... wait(s2); d.b++; signal(s2);... }
6
2007-03-16 Mehdi Amirijoo6 Transactional Memory Focus on where atomic execution is necessary Not how it is implemented Process P1 {... atomic { d.a++; }... } Process P2 {... atomic { d.b++; }... }
7
2007-03-16 Mehdi Amirijoo7 Transactional Memory Statements within atomic appear to have serialization with respect to: Other transactions Reads and writes outside of transactions Nested transactions Optimistic speculation (transactions) vs pessimistic waiting (locks) Roll-back due to writes outside the transaction Process P1 { atomic { atomic {... } }...
8
2007-03-16 Mehdi Amirijoo8 Conditional Waiting Conditional critical region (CCR) Similar property as critical sections, and A process can enter the critical region iff the condition evaluates to be true. In ATOMOS: atomic { if ( !condition(condition_variables) ) { watch condition_variables; retry;} // critical region }
9
2007-03-16 Mehdi Amirijoo9 Conditional Waiting Class Buffer { public int get (){ synchronized (this) { while (!available) wait(); available = false; notifyAll(); return contents;}} public void put(int value) { synchronized (this) { while (available) wait(); contents = value; available = true; notifyAll();}} } Class Buffer { public int get() { atomic { if (!available) { watch available; retry;} available = false; return contents;}} public void put (int value) { atomic { if (available) { watch available; retry;} contents = value; available = true;}} }
10
2007-03-16 Mehdi Amirijoo10 Conditional Waiting synchronized (lock) { count++; if (count != nThreads) lock.wait(); else lock.notifyAll(); } atomic { count++; if (count != nThreads) { watch count; retry; }} Example: Barrier synchronization atomic { count++; } atomic { if (count != nThreads) { watch count; retry; }}
11
2007-03-16 Mehdi Amirijoo11 Nesting In databases transactions usually reduce isolation to improve performance Communication from within uncommitted transactions! Closed-nested transaction: Results of children visible only to parent Open-nested Transaction: Results of children visible globally
12
2007-03-16 Mehdi Amirijoo12 Nesting
13
2007-03-16 Mehdi Amirijoo13 Nesting public static int generateID { atomic { return id++; } } public static void createOrder (...) { atomic { Order order = new Order(); order.setID(generateID()); // finish initialization of order. This could // include more calls to generateID. orders.put(new Integer(order.getID()),order); } }
14
2007-03-16 Mehdi Amirijoo14 Nesting public static open int generateID { open { return id++; } } public static void createOrder (...) { atomic { Order order = new Order(); order.setID(generateID()); // finish initialization of order. This could // include more calls to generateID. orders.put(new Integer(order.getID()),order); } }
15
2007-03-16 Mehdi Amirijoo15 Evaluation Goal: Compare ATOMOS with Java Synchronized → atomic wait(), notify(), notifyAll() → watch, retry 1 to 32 CPU:s (no thread migration) No garbage collection Measure execution time
16
2007-03-16 Mehdi Amirijoo16 Evaluation Benchmark focusing on business object manipulation Only 1% chance of contention between threads. ATOMOS does not incur additional bottlenecks
17
2007-03-16 Mehdi Amirijoo17 Evaluation Benchmark focusing on business object manipulation Hashtable and HashMap use only one mutex ConcurrentHashMap uses fine-grained locking Atomos uses single atomic statement
18
2007-03-16 Mehdi Amirijoo18 Conclusion Transactional programming simplifies design of programs Conditional waiting enables CCR Open nesting increases performance by reducing time to commit Evaluation shows that the approach is scalable with the number of processors
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.