E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.

Slides:



Advertisements
Similar presentations
Hazard Pointers: Safe Memory Reclamation of Lock-Free Objects
Advertisements

Wait-Free Queues with Multiple Enqueuers and Dequeuers
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
1 Chapter 4 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
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.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Scalable Synchronous Queues By William N. Scherer III, Doug Lea, and Michael L. Scott Presented by Ran Isenberg.
Progress Guarantee for Parallel Programs via Bounded Lock-Freedom Erez Petrank – Technion Madanlal Musuvathi- Microsoft Bjarne Steensgaard - Microsoft.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
CS510 Advanced OS Seminar Class 10 A Methodology for Implementing Highly Concurrent Data Objects by Maurice Herlihy.
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
CS533 - Concepts of Operating Systems 1 Class Discussion.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University, St. Louis
Practical and Lock-Free Doubly Linked Lists Håkan Sundell Philippas Tsigas.
CSE 532: Midterm Review CSE 532 Fall 2013 Midterm Exam 80 minutes, during the usual lecture/studio time: 10:10am to 11:30am on Monday October 21, 2013.
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.
CSE 425: Concurrency III Monitors A monitor is a higher level construct for synchronizing multiple threads’ access to a common code segment –Can implement.
Håkan Sundell, Chalmers University of Technology 1 NOBLE: A Non-Blocking Inter-Process Communication Library Håkan Sundell Philippas.
November 15, 2007 A Java Implementation of a Lock- Free Concurrent Priority Queue Bart Verzijlenberg.
A Consistency Framework for Iteration Operations in Concurrent Data Structures Yiannis Nikolakopoulos A. Gidenstam M. Papatriantafilou P. Tsigas Distributed.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
CSE 425: Concurrency II Semaphores and Mutexes Can avoid bad inter-leavings by acquiring locks –Guard access to a shared resource to take turns using it.
A Methodology for Creating Fast Wait-Free Data Structures Alex Koganand Erez Petrank Computer Science Technion, Israel.
Non-Blocking Concurrent Data Objects With Abstract Concurrency By Jack Pribble Based on, “A Methodology for Implementing Highly Concurrent Data Objects,”
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
Wait-Free Multi-Word Compare- And-Swap using Greedy Helping and Grabbing Håkan Sundell PDPTA 2009.
CS510 Concurrent Systems Jonathan Walpole. A Methodology for Implementing Highly Concurrent Data Objects.
Software Transactional Memory Should Not Be Obstruction-Free Robert Ennals Presented by Abdulai Sei.
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Techniques and Structures in Concurrent Programming Wilfredo Velazquez.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
C H A P T E R E L E V E N Concurrent Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
November 27, 2007 Verification of a Concurrent Priority Queue Bart Verzijlenberg.
1 The Computability of Relaxed Data Structures: Queues and Stacks as Examples The Computability of Relaxed Data Structures: Queues and Stacks as Examples.
How & When The Kernel Runs David Ferry, Chris Gill Department of Computer Science and Engineering Washington University, St. Louis MO
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects MAGED M. MICHAEL PRESENTED BY NURIT MOSCOVICI ADVANCED TOPICS IN CONCURRENT PROGRAMMING,
CS510 Concurrent Systems Tyler Fetters. A Methodology for Implementing Highly Concurrent Data Objects.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Agenda  Quick Review  Finish Introduction  Java Threads.
Read-Copy-Update Synchronization in the Linux Kernel 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis.
Kernel Synchronization David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
C++11 Atomic Types and Memory Model
Lecture 20: Consistency Models, TM
Event Handling Patterns Asynchronous Completion Token
Håkan Sundell Philippas Tsigas
Department of Computer Science, University of Rochester
Overview of the Lab 2 Assignment: Linux Scheduler Profiling
A Lock-Free Algorithm for Concurrent Bags
CS510 Concurrent Systems Jonathan Walpole.
Anders Gidenstam Håkan Sundell Philippas Tsigas
The Active Object Pattern
CS510 Concurrent Systems Jonathan Walpole.
Kernel Synchronization II
CS510 - Portland State University
Thread Synchronization
Lecture 22: Consistency Models, TM
Monitor Object Pattern
Testing and Debugging Concurrent Code
Kernel Synchronization I
Userspace Synchronization
CS510 Advanced Topics in Concurrency
CS510 Concurrent Systems Jonathan Walpole.
Presentation transcript:

E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis C++11 Lock-free Data Structures

Lock-Free and Wait-Free Semantics Lock-free behavior never blocks (but may live-lock) –Suspension of one thread doesn’t impede others’ progress –Tries to do something, if cannot just tries again –E.g., while(head.compare_exchange_weak(n->next,n)); Wait-free behavior never starves a thread –Progress of each is guaranteed (bounded number of retries) Lock-free data structures try for maximum concurrency –E.g., ensuring some thread makes progress at every step –May not be strictly wait-free but that’s something to aim for Watch out for performance costs in practice –E.g., atomic operations are slower, may not be worth it –Some platforms may not relax memory consistency well

Lock-Free Stack Case Study Even simplest version of push requires careful design –Allocate/initialize, then swap pointers via atomic operations Need to deal with memory reclamation –Three strategies: thread counts, hazard pointers, ref counts Memory models offer potential performance gains –E.g., if relaxed or acquire/release consistency is in fact weaker on the particular platform for which you’re developing –Need to profile that, e.g., as we did in the previous studio Resulting lock free stack design is a good approach –E.g., Listing 7.12 in [Williams] –Please feel free to use (with appropriate citation comments) in your labs (we’ll code this up in the studio exercises)

Lock-Free Queue Case Study Contention differs in lock-free queue vs. stack –Enqueue/dequeue contention depends on how many nodes are in the queue, whereas push/pop contend unless empty –Synchronization needs (and thus design) are different Application use cases also come into play –E.g., single-producer single-consumer queue is much simpler and may be all that is needed in some cases –Service configuration, template meta-programming, other approaches can enforce necessary properties of its use Multi-thread-safe enqueue and dequeue operations –Modifications (to e.g., reference-counting) may be needed –May need to use work-stealing to be lock free (!)

Lock Free Design Guidelines Prototype data structures using sequential consistency –Then analyze and test thread-safety thoroughly –Then look for meaningful opportunities to relax consistency Use a lock-free memory reclamation scheme –Count threads and then delete when quiescent –Use hazard pointers to track threads accesses to an object –Reference count and delete in a thread-safe way –Detach garbage and delegate deletion to another thread Watch out for the ABA problem –E.g., with coupled variables, pop-push-pop issues Identify busy waiting, then steal or delegate work –E.g., if thread would be blocked, “help it over the fence”