1 Lock-Free Linked Lists Using Compare-and-Swap by John Valois Speaker’s Name: Talk Title: Larry Bush.

Slides:



Advertisements
Similar presentations
Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Håkan Sundell Philippas Tsigas.
Advertisements

Operating Systems Part III: Process Management (Process Synchronization)
Synchronization. How to synchronize processes? – Need to protect access to shared data to avoid problems like race conditions – Typical example: Updating.
1 Chapter 4 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Concurrent Programming Problems OS Spring Concurrency pros and cons Concurrency is good for users –One of the reasons for multiprogramming Working.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.
Scalable and Lock-Free Concurrent Dictionaries
Wait-Free Reference Counting and Memory Management Håkan Sundell, Ph.D.
CPSC 668Set 18: Wait-Free Simulations Beyond Registers1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
A Lock-Free Multiprocessor OS Kernel1 Henry Massalin and Calton Pu Columbia University June 1991 Presented by: Kenny Graunke.
Scalable Synchronous Queues By William N. Scherer III, Doug Lea, and Michael L. Scott Presented by Ran Isenberg.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
It Ain’t the Meat, it’s the Notion Why Theory is Essential to Teaching Concurrent Programming Maurice Herlihy Brown University.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
10/31/20111 Relativistic Red-Black Trees Philip Howard 10/31/2011
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
1 Concurrency: Deadlock and Starvation Chapter 6.
Synchronization (other solutions …). Announcements Assignment 2 is graded Project 1 is due today.
Simple, Fast and Practical Non- Blocking and Blocking Concurrent Queue Algorithms Maged M. Michael & Michael L. Scott Presented by Ahmed Badran.
1 Chapter 5 Concurrency. 2 Concurrency 3 4 Mutual Exclusion: Hardware Support Test and Set Instruction boolean testset (int *i) { if (*i == 0) { *i.
SUPPORTING LOCK-FREE COMPOSITION OF CONCURRENT DATA OBJECTS Daniel Cederman and Philippas Tsigas.
Synchronization Methods for Multicore Programming Brendan Lynch.
Practical and Lock-Free Doubly Linked Lists Håkan Sundell Philippas Tsigas.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
Parallel Programming Philippas Tsigas Chalmers University of Technology Computer Science and Engineering Department © Philippas Tsigas.
Simple Wait-Free Snapshots for Real-Time Systems with Sporadic Tasks Håkan Sundell Philippas Tsigas.
CS510 Concurrent Systems Jonathan Walpole. A Lock-Free Multiprocessor OS Kernel.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS Fall 2011 Prof. Jennifer Welch CSCE 668 Set 18: Wait-Free Simulations Beyond Registers 1.
Håkan Sundell, Chalmers University of Technology 1 NOBLE: A Non-Blocking Inter-Process Communication Library Håkan Sundell Philippas.
Chapter 2/6 –Critical Section Problem / Mutual exclusion progress, bounded wait –Hardware Solution disable interrupts –problems ? –Software Solution busy.
Håkan Sundell, Chalmers University of Technology 1 Simple and Fast Wait-Free Snapshots for Real-Time Systems Håkan Sundell Philippas.
Challenges in Non-Blocking Synchronization Håkan Sundell, Ph.D. Guest seminar at Department of Computer Science, University of Tromsö, Norway, 8 Dec 2005.
Non-blocking Data Structures for High- Performance Computing Håkan Sundell, PhD.
State Teleportation How Hardware Transactional Memory can Improve Legacy Data Structures Maurice Herlihy and Eli Wald Brown University.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
1 Chapter 9 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Wait-Free Multi-Word Compare- And-Swap using Greedy Helping and Grabbing Håkan Sundell PDPTA 2009.
Practical concurrent algorithms Mihai Letia Concurrent Algorithms 2012 Distributed Programming Laboratory Slides by Aleksandar Dragojevic.
CS510 Concurrent Systems Why the Grass May Not Be Greener on the Other Side: A Comparison of Locking and Transactional Memory.
Range Queries in Non-blocking k-ary Search Trees Trevor Brown Hillel Avni.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects Maged M. Michael Presented by Abdulai Sei.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Synchronicity Introduction to Operating Systems: Module 5.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Distributed Algorithms (22903) Lecturer: Danny Hendler The wait-free hierarchy and the universality of consensus This presentation is based on the book.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects MAGED M. MICHAEL PRESENTED BY NURIT MOSCOVICI ADVANCED TOPICS IN CONCURRENT PROGRAMMING,
CS4315A. Berrached:CMS:UHD1 Process Synchronization Chapter 8.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Read-Copy-Update Synchronization in the Linux Kernel 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis.
Process Synchronization Presentation 2 Group A4: Sean Hudson, Syeda Taib, Manasi Kapadia.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
6.852 Lecture 21 ● Techniques for highly concurrent objects – coarse-grained mutual exclusion – read/write locking – fine-grained locking (mutex and read/write)
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Hazard Pointers C++ Memory Ordering Issues
Background on the need for Synchronization
Håkan Sundell Philippas Tsigas
Lock-Free Linked Lists Using Compare-and-Swap
A Lock-Free Algorithm for Concurrent Bags
Routing Without Flow Control Hot-Potato Routing Simulation
A Concurrent Lock-Free Priority Queue for Multi-Thread Systems
Multicore programming
Presentation transcript:

1 Lock-Free Linked Lists Using Compare-and-Swap by John Valois Speaker’s Name: Talk Title: Larry Bush

2 Concurrent Object P1P1 P2P2 PnPn Shared Memory

3 Lock-Free No Mutual Exclusion Appear Atomic Lamport Massalin and Pu

4 Lock-Free Linked Lists?

5 bool Compare&Swap ( Type * x, Type old, Type new) { // BEGIN ATOMIC if *x != old { *x = new; return TRUE; } else { return FALSE } // END ATOMIC } Compare&Swap Synchronization Primitive

6 Why is this important ? Avoids Mutual Exclusion Problems Convoying Deadlock Priority Inversion Busy Waiting Blocking

7 Universal methods are not efficient (Herlihy). Massalin and Pu’s method required the uncommon double word Compare&Swap. Limitations of current implementations

8 As quick as spin locks Without blocking or busy waiting (wait free) Benefits of new implementations

9 Part 2 Concurrent Linked List Cursor

10 Traversal ( no problem ) Cursor

11 Insert ( small problem ) s p q

12 Insert ( small problem ) s p q

13 Insert ( small problem ) s p q swing pointer

14 Delete bad

15 Delete bad

16 Delete ( big problem ) Cursor ad c b

17 Delete ( big problem ) Cursor ad c b

18 Delete ( big problem ) Cursor ad c b

19 Delete ( big problem ) ad c b Cursor

20 Auxiliary nodes ad cb

21 Delete ( with auxiliary nodes ) ad c b

22 Delete ( with auxiliary nodes ) ad c b

23 Delete ( with auxiliary nodes ) ad c b

24 Delete ( with auxiliary nodes ) ad c b

25 Conclusion Allows concurrent operations Good for: parallel processing distributed memory Should be used everywhere

26 Questions/Facts

27 ABA problem s p q swing pointer

28 ABA Solutions Double Compare&Swap No Cell Reuse Memory Management

29 Aux Nodes Insertion of new cells takes place between an auxiliary node and an existing regular cell. Chains of auxilary nodes are allowed. An auxilary node is not required to have a real cell node before and after it.

30 Related Work Lamport Herlihy Massalin and Pu

31 Lock-Free Structures & Memory Management Techniques for linked list, dictionary and tree. Contributions

32 Why do you say this is lock-free if it uses a mutual exclusion primitive? Limited to atomic actions provided by the hardware. Only when swinging pointers. Allows simultaneous traversal, insertion and deletion. Lamport (made the distinction) Massalin and Pu (coined the term)

33 ptr = find ptr of interest repeat old = Read( ptr ); new = compute new pointer value r = Compare&Swap(ptr, old, new) until ( r = TRUE ) } Swinging the Pointer

34 q = new cell Repeat r = SafeRead ( p -> next ) Write ( q -> next, r ) until Compare&Swap( p -> next, r, q ) Insert ( p, x )

35 node * target;// -> data node * pre_aux; // -> preceding auxiliary node node * pre_cell; // -> previous cell struct Cursor { };

36 // Updates pointers in the cursor so that it becomes valid. // removes double aux_node. Update(cursor c) { };

37 c.pre_cell = next // deletes cell back_link = c->pre_cell delete pre_aux Concurrent deletions may stall process and create chains of aux nodes. The last deletion follows the back_links of the deleted cells. After all deletions the list will have no extra aux_nodes Try_delete(cursor c) { };

38 Universal Algorithm (a.k.a. Universal Method) An algorithm that provides lock-free functionality for ANY generic ADT is called universal. Universal meaning “for any.” This requires a powerful synchronization primitive. This is an application that defines a primitives strength. Universal Primitive A universal primitive can be used to provide lock-free functionality for any generic Data Type. A universal primitive can also solve the consensus problem. Analogous Problems Generic Lock-Free ADT is analogous to the consensus problem. If a primitive is powerful enough to solve one it can also solve the other. Universal

39 Can be implemented using Compare&Swap Test&Set Sets new value to TRUE. Fetch&Add Adds an arbitrary value to shared variable. Test&Set Fetch&Add

40 Created algorithms and data structures that directly implement a non-blocking singly-linked list. Allows multiple processes to traverse, insert and delete. Using only commonly available Compare&Swap. Single word version Commonly available on most systems Valois

41 An implementation is wait-free if every process finishes in a bounded number of steps, regardless of interleaving. Wait-Free

42 Discovered that mutual exclusion problems can be avoided using lock-free methods. Gave the first lock-free algorithm for the single writer/ multiple reader shared variable. Led to more research on the topic. 27 years Lamport