CS510 Concurrent Systems Jonathan Walpole.

Slides:



Advertisements
Similar presentations
Stack and Queues using Linked Structures Kruse and Ryba Ch 4.
Advertisements

Hazard Pointers: Safe Memory Reclamation of Lock-Free Objects
Wait-Free Queues with Multiple Enqueuers and Dequeuers
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
Ceng-112 Data Structures I Chapter 5 Queues.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects
CS252: Systems Programming Ninghui Li Program Interview Questions.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.
Wait-Free Reference Counting and Memory Management Håkan Sundell, Ph.D.
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
CS Data Structures II Review COSC 2006 April 14, 2017
Scalable Synchronous Queues By William N. Scherer III, Doug Lea, and Michael L. Scott Presented by Ran Isenberg.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
Simple, Fast, and Practical Non- Blocking and Blocking Concurrent Queue Algorithms Presenter: Jim Santmyer By: Maged M. Micheal Michael L. Scott Department.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
CS533 - Concepts of Operating Systems 1 Class Discussion.
Algorithms and Data Structures Representing Sequences by Arrays and Linked Lists.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Chapter 8 Data Abstractions Introduction to CS 1 st Semester, 2015 Sanghyun Park.
CS510 Concurrent Systems Jonathan Walpole. A Lock-Free Multiprocessor OS Kernel.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
Review of Stacks and Queues Dr. Yingwu Zhu. How does a Stack Work? Last-in-First-out (LIFO) data structure Adding an item Push operation Removing an item.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Queues.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects Maged M. Michael Presented by Abdulai Sei.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
CS510 Concurrent Systems Jonathan Walpole. A Methodology for Implementing Highly Concurrent Data Objects.
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects MAGED M. MICHAEL PRESENTED BY NURIT MOSCOVICI ADVANCED TOPICS IN CONCURRENT PROGRAMMING,
1 Midterm 1 on Friday February 12 Closed book, closed notes No computer can be used 50 minutes 4 questions Write a function Write program fragment Explain.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture3.
Review Array Array Elements Accessing array elements
Processes and threads.
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Understanding Algorithms and Data Structures
Week 4 - Friday CS221.
Hazard Pointers C++ Memory Ordering Issues
By Michael Greenwald and David Cheriton Presented by Jonathan Walpole
Håkan Sundell Philippas Tsigas
CS 1114: Implementing Search
Department of Computer Science, University of Rochester
Stacks and Queues.
Joint work with Yong Li, Xinyu Feng, Zhong Shao and Yu Zhang
Stack and Queue APURBO DATTA.
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Von Neumann model - Memory
A Lock-Free Algorithm for Concurrent Bags
CS510 Concurrent Systems Jonathan Walpole.
Distributed Algorithms (22903)
Anders Gidenstam Håkan Sundell Philippas Tsigas
Pointers and Linked Lists
Stacks, Queues, and Deques
Concurrent Data Structures Concurrent Algorithms 2016
CS510 - Portland State University
Von Neumann model - Memory
CMSC 202 Trees.
Data structures.
Software Transactional Memory Should Not be Obstruction-Free
Model Checking of a lock-free stack
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
CS510 Advanced Topics in Concurrency
Instructor: Dr. Michael Geiger Spring 2019 Lecture 29: Linked queues
CS510 Concurrent Systems Jonathan Walpole.
Stacks, Queues, and Deques
CSCS-200 Data Structure and Algorithms
Presentation transcript:

CS510 Concurrent Systems Jonathan Walpole

Hazard Pointers: Safe Memory Reclamation of Lock-Free Objects Maged M. Michael

The Problem - Lock-free algorithms assume that threads can operate on any object at any time - Freeing memory could break this assumption - How can we free memory of deleted nodes in a safe and lock-free manner?

Prior Work - No reuse Recycling of constant static storage Type safe memory Reference counts with DCAS or CAS2

Goals of Hazard Pointers Readers inform writers of references they hold Bound the number of unreclaimed objects Tolerance for thread failures (wait-free) No special hardware of kernel support needed Suitable for user or kernel use

Hazard Pointers Each thread has a set of pointers that only it writes, but other threads can read Each pointer is either null or points to an object the thread is currently using Before accessing any dynamic object a thread must first store a pointer to it in its list Thread 0 1 2 … n Objects

Retired List Each thread also has a list of nodes it has deleted and would like to free When the length of this list reaches R, the thread scans the hazard pointer lists of all other threads to see if its safe to free any of its nodes. RetNod HP – Thread 2 HP – Thread 3 Thread 1

The ABA Problem Process 1 has a copy of a pointer to Object x Process 2 deletes object x, frees its memory, and reuses the same memory to create a new object y Process 1 applies CAS on the address of object x which is the same as that of object y The CAS succeeds but the object has changed! Process 1 Process 2 Pointer P Pointer P Y X Object

ABA Problem Solved Process 1 has a hazard pointer to object x Process 2 deletes object x and moves object x to its retired nodes list Process 1 can still safely access object x Hazard Pointer disallows freeing the memory and hence reuse of the same memory The ABA problem cannot occur with Hazard Pointers Process 1 Process 2 Retired Nodes List Hazard Pointers X Object

Hazard Pointer Types

Retiring Nodes

Lock Free Enqueue

Lock Free Enqueue Access hazard ABA hazard Access and ABA hazard

Lock Free Enqueue

Lock Free Dequeue

Lock Free Dequeue Access hazard ABA hazard

Lock Free Dequeue

Lock Free Stack Push

Lock Free Stack Pop

Lock Free Stack Pop

Lock Free Stack Pop Access Access hazard ABA hazard

Lock Free Stack Pop

Performance (Queues)

Conclusions Safe memory reclamation Solves ABA problem Wait-free if the original algorithm is wait-free Reasonable performance? readers must now write and these writes require memory barriers!