1 / 14

Lock-Free Binary Search Tree

Lock-Free Binary Search Tree. Presented by Joanna Helga From draft paper “Lock-Free Binary Search Trees” by Eric Ruppert , Panagiota Fatourou , and Faith Ellen. Binary Search Tree (BST). Implements dictionary abstract data structure Each node can have 0-2 children

Download Presentation

Lock-Free Binary Search Tree

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lock-Free Binary Search Tree Presented by Joanna Helga From draft paper “Lock-Free Binary Search Trees” by Eric Ruppert, PanagiotaFatourou, and Faith Ellen

  2. Binary Search Tree (BST) Implements dictionary abstract data structure Each node can have 0-2 children All nodes in left subtree of X has keys that smaller than key of X All nodes in right subtree of X has keys that greater than (or equal to) key of X B A D C G E H

  3. Leaf Oriented BST Property #1 Real keys are stored in leaf Internal nodes stores dummy keys and exactly has 2 children Leaves stores only a key B A D C G E H

  4. Leaf Oriented BST Property #2 Duplicate keys are not allowed Keys stored in internal nodes are not real keys, so they may have duplicates H A H X C H <X ≥X E H

  5. Insert Operation We also need to know this pointer, which is D’s parent Insert(E) search for location create a node for E create dummy node with key=max(E,D) point its left and right child to D and E change B’s pointer to the new dummy node B E D E α

  6. Delete Operation We also need to know this pointer, which is C’s grandparent Delete(C) Search C’s location Change B’s child pointer to C’s sibling B D α And this pointer, which can be found if we know C’s parent C β

  7. Update Operations • Update operations only change 1 pointer in the shared data structure • However, simply using Compare-and-swap for updating this pointer can have some problem B B E α Insert Delete D E α β

  8. Problem Example #1 B Problem arises when op1 splice node D out of tree, while op2 tries to update its child pointer op1:Delete(C) A D op2: Delete(E) C G E is not deleted ! E H

  9. Problem Example #2 B op2: Delete(E) Problem arises when op2 splice node G out of tree, while op1 tries to update its child pointer A D C G op1: Insert(F) F F is not inserted ! E F H

  10. Mark & Flag Bits • To overcome the previous problem, we add MARK and FLAG bits to each node • MARK bit indicate that a node will be spliced out soon • FLAG bit indicate that a node will have one of its child pointer changed soon We want to avoid a node being spliced out and changed its child pointer at same time. This can be achieved by using these 2 bits, that stored in a single word.

  11. Key Steps of Insert CAS’s for Insert: • Flag B • Change it’s child pointer • unFlag B B B E D E α

  12. Key Steps of Delete CAS’s for Delete • Flag B • Mark D • Change B’s child pointer • unFlag B B B D D α C β

  13. Lock-Free Property • MARK and FLAG bits behaves like a lock • When an operation tries to update something, it has to own the lock first, and unlock it after the update is done If a process who holds the lock dies, it will prevent other processes to access that part of the tree forever ! Use HELPING procedure to prevent locking

  14. Helper Node Before a process tries to hold a lock, it stores enough information on a Helper Node • Leaf pointer • Parent pointer • Grandparent pointer • Last known MARK and FLAG bits statuses of parent node • Pointer to the node to be inserted (for Insert only) A pointer to this helper node is stored in same field as MARK and FLAG bit

More Related