Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Hazard Pointers: Safe Memory Reclamation of Lock-Free Objects
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A AAA A A A AA A Proving that non-blocking algorithms don't block.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects
CS252: Systems Programming Ninghui Li Program Interview Questions.
CS510 – Advanced Operating Systems 1 The Synergy Between Non-blocking Synchronization and Operating System Structure By Michael Greenwald and David Cheriton.
Scalable and Lock-Free Concurrent Dictionaries
Wait-Free Reference Counting and Memory Management Håkan Sundell, Ph.D.
Review of Stacks and Queues Dr. Yingwu Zhu. Our Focus Only link-list based implementation of Stack class Won’t talk about different implementations of.
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Scalable Synchronous Queues By William N. Scherer III, Doug Lea, and Michael L. Scott Presented by Ran Isenberg.
Concurrent Data Structures in Architectures with Limited Shared Memory Support Ivan Walulya Yiannis Nikolakopoulos Marina Papatriantafilou Philippas Tsigas.
CPSC 388 – Compiler Design and Construction
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
Computer Laboratory Practical non-blocking data structures Tim Harris Computer Laboratory.
Simple, Fast, and Practical Non- Blocking and Blocking Concurrent Queue Algorithms Presenter: Jim Santmyer By: Maged M. Micheal Michael L. Scott Department.
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
CS533 - Concepts of Operating Systems 1 Class Discussion.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Who’s Afraid of a Big Bad Lock Nir Shavit Sun Labs at Oracle Joint work with Danny.
An example demonstrating the ABA problem Xinyu Feng University of Science and Technology of China.
DATA STRUCTURES OPTIMISATION FOR MANY-CORE SYSTEMS Matthew Freeman | Supervisor: Maciej Golebiewski CSIRO Vacation Scholar Program
CS510 Concurrent Systems Jonathan Walpole. A Lock-Free Multiprocessor OS Kernel.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
11/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Queues.
DOUBLE INSTANCE LOCKING A concurrency pattern with Lock-Free read operations Pedro Ramalhete Andreia Correia November 2013.
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects Maged M. Michael Presented by Abdulai Sei.
The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with Linux Guniguntala et al.
Gal Milman Based on Chapter 10 (Concurrent Queues and the ABA Problem) in The Art of Multiprocessor Programming by Herlihy and Shavit Seminar 2 (236802)
Understanding General Software Development Lesson 3.
MULTIVIE W Slide 1 (of 21) Software Transactional Memory Should Not Be Obstruction Free Paper: Robert Ennals Presenter: Emerson Murphy-Hill.
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,
Scalable lock-free Stack Algorithm Wael Yehia York University February 8, 2010.
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.
Slides on threads borrowed by Chase Landon Cox. Thread states BlockedReady Running Thread is scheduled Thread is Pre-empted (or yields) Thread calls Lock.
1 Queues (Continued) Queue ADT Linked queue implementation Array queue implementation Circular array queue implementation Deque Reading L&C , 9.3.
Understanding General Software Development Lesson 3.
Week 15 – Monday.  What did we talk about last time?  Tries.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Chapter 12 – Data Structures
Hazard Pointers C++ Memory Ordering Issues
Håkan Sundell Philippas Tsigas
CS 1114: Implementing Search
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Data Structures Interview / VIVA Questions and Answers
Week 15 – Monday CS221.
Joint work with Yong Li, Xinyu Feng, Zhong Shao and Yu Zhang
Stack and Queue APURBO DATTA.
A Lock-Free Algorithm for Concurrent Bags
CS510 Concurrent Systems Jonathan Walpole.
Anders Gidenstam Håkan Sundell Philippas Tsigas
Pointers and Linked Lists
CS510 Concurrent Systems Jonathan Walpole.
Lesson Objectives Aims
CS510 - Portland State University
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
Yiannis Nikolakopoulos
Stacks: Implemented using Linked Lists
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Multicore programming
CS510 Advanced Topics in Concurrency
CS210- Lecture 6 Jun 13, 2005 Announcements
CS510 Concurrent Systems Jonathan Walpole.
Stacks, Queues, and Deques
Presentation transcript:

Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer

The Problem Lock-free approaches scale (with the number of processors) and avoid deadlock issues. Lock-free means concurrent access which is problematic for storage reclamation Previous papers described lock-free techniques that updated in place or assumed dedicated constant width data; i.e., storage was not collected and reused.

The Constraints Detection Property: –Distinguish live objects from garbage Reclamation Property: –Reclaim garbage objects’ storage Safety Properties: –Cannot reclaim “live” objects –Cannot access reclaimed objects Liveness Property: –“Garbage” objects eventually reclaimed Note: These are more than those identified in the paper

The Lock-Free Idea Do all the “work” on the side, but accessible from a pointer Use CAS to update, in place, the pointer Do this in a loop *p_new = new data do { p_old = p … } while (!cas(&p, p_old, p_new)) When can this be collected (reclaimed)?

Example: Lock-Free Stack push(node): do { t = TOP node  next = TOP } until CAS(&TOP,t,node) node pop: do { t = TOP if t == NULL return NULL next = t  next } until CAS(&TOP,t,next) return t

ABA Problem Suppose a list has A  B  C Thread X: t = TOP; …; next = t  next Thread Y: N = POP: t = TOP; …; next = t  next; CAS(&TOP, t, next) POP: t = TOP; …; next = t  next; CAS(&TOP, t, next) List is now just “C”, since A and B have been popped PUSH(N): t = TOP; A  next = TOP; CAS (&TOP, t, A) List is now “A  C”, since we pushed A Thread X continues: cas(&TOP,t,next) List is now “B  C” Issue: What if Thread “Y” had reclaimed “B” because it “knew” that it would never use it?

POP With Tags node pop: do { = TOP if t == null return null next = t  next } until CAS(&TOP,, ) return t Since tag is monotonic with respect to calls to pop, the A—B—A problem is eliminated as long the number of calls to pop is limited.

Hazard Pointer Thread … n Hazard Pointers Objects Hazard Pointers identify the objects that the thread will access.

“Releasing” an Object Thread n When the “object” is released by thread n, the pointer on the hazard list is removed. We add the pointer to the object to the “to be released” list. After the object reference is added to the List we check the length of the list and if it is greater than “R”, we “scan” to see what can be reclaimed. to be released

Reclaiming Storage hp_1 hp_2 hp_n Thread n, scans the hp_i lists for each thread, if ptr_k not any hp list, then it can be reclaimed. ptr_k

Problem 1 of 2 Problem 1: –Thread X removes node N ptr (count < R) –Thread Y removes node N ptr (count >= R) Scan and reclaim N –Thread X removes node M ptr (count >= R) Scan and reclaim N

Problem 2 of 2 free Thread X scans list for “u”. At this “point”, thread Y runs and adds “u”. Thread Y HP list u Since Thread X did not see “M” it will reclaim the storage. But, Y has “M” on its hazard list.

Transforming a FIFO Queue: Identifying the hazards Access hazard because *t may have been removed and reclaimed ABA hazards Access and ABA hazard ABA hazard Note: Only one hazard pointer is needed, since “t” is the only hazard reference.

Transforming a FIFO Queue: Adding hazard pointers Protect *t data This is supposed to make sure that t is “safe” – that the “t” protected by hp0 is The same as Tail So, hp0 “protects” t only during the time this routine is active; but, it might protect it much longer!

Transforming a FIFO Queue: Dequeue Don’t’ want head to be reclaimed. We will use it later! h (head) will end up on the “to be released” list. Note that “next” is still on the hp list – so I am not sure how another processor can retire it?

Double Linked List: Something Curious What’s this about?

Performance Performance of FIFO queue

Performance Hash Table: Load Factor = 5

Author Notes Superior Performance of hazard pointers –operate directly on shared objects without need for managing locks –read-only operations do not result in writes other than private hazard pointers –no spinning –progress guaranteed under preemption

Conclusion (mine) Paper’s attempt at formalism was not useful Idea of hazard pointers is simple, but implementations are broken in one way or another Author seems confused about ABA problem and garbage collection