1 / 16

Model Checking Lock-Free Binary Search Tree

Model Checking Lock-Free Binary Search Tree. Presented by Joanna Helga. Leaf Oriented BST. Implements Dictionary ADT Operations: Find, Insert, Delete 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.

mauricej
Télécharger la présentation

Model Checking 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. Model CheckingLock-Free Binary Search Tree Presented by Joanna Helga

  2. Leaf Oriented BST Implements Dictionary ADT Operations: Find, Insert, Delete 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

  3. Node Structure Node 2 key : int Leaf Internal left : Node right : Node Internal HelperNode int left : Node right : Node update : AtomicStampedReference<Flag> Helper Node A A 0=Clean 1=IFlag 2=DFlag 3=Mark

  4. Insert Is parent node clear? parent Insert(E) search for location create Leaf(E) create Internal(max(E,D)) point its left and right child to D and E Flag B change B’s pointer to the new Internal node Unflag B B B E leaf D E α

  5. Delete Is grandparent node clear? parent grandparent Delete(C) Search C’s location Flag B (grandparent) Mark D (parent) Change B’s child pointer to C’s sibling Unflag B B B Is parent node clear? D D α leaf C β

  6. SearchReturn Class SearchReturn l : Node p : Node gp : Node pupdate: AtomicStampedReference<Flag> gpupdate : AtomicStampedReference<Flag>

  7. Helper Node Structure Flag p : Node l : Node IFlag DFlag newinternal: Node gp : Node pupdate : AtomicStampedReference<Flag>

  8. Checking Dictionary d; Leaf l; int mykey; … d.Insert(mykey); l = d.Find(mykey); assert(l != null); assert(l.key == mykey); d.Delete(mykey); l = d.Find(mykey); assert(l == null); insert(10) || insert(20) insert(10) insert(20) delete(10) || delete(20) insert(10) delete(10) || insert(20)

  9. Test #1 assert error d.Insert(mykey); l = d.Find(mykey); assert(l != null); assert(l.key == mykey); null pointer exception Insert operation returns “TRUE”, but the key was not inserted

  10. Insert - Detailed flag gp SearchRet gpupdate pupdate gp p l update flag p update if (pupdate.stamp = clean) then create new node create helper node op p.update.CAS(pupdate, <op,1>) if (CAS successful) then // actually modify the BST reference reference search location if (pupdate.stamp = clean) then // try insert here… else // help gp here… stamp stamp l why we need CAS here? CAS always successful !

  11. Insert - Fixed flag gp SearchRet int gpflag gpstamp pflag pstamp gp p l update int flag p update reference reference stamp stamp if (p.update.stamp = clean) then create new node create helper node op p.update.CAS(<pflag,0>, <op,1>) if (CAS successful) then // actually modify the BST l

  12. Test #2 insert(10) insert(20) delete(10) || delete(20) null pointer exception

  13. Delete - Detailed flag gp SearchRet gpflag gpstamp pflag pstamp gp p l update flag p update // try delete create helper node op gp.update.CAS(<gpflag,0>, <op,2>) if(CAS successful) // try modify BST else help(gp.update) search if (gp.update.stamp != 0) help(gp.update) else if(p.update.stamp != 0) help(p.update) else //try delete… reference reference stamp stamp l why we need CAS here? null pointer exception

  14. Help & HelpMarked help(AtomicStampedReference<Flag> update){ if(update.stamp = 1) //1=iflag helpinsert(update.reference); else if(update.stamp = 3) //3=mark helpmarked(update.reference); else if(update.stamp = 2) //2=dflag; helpdelete(update.reference); } private void helpmarked(DFlag op){ // Modify BST } A node is marked, but doesn’t have pointer to HelperNode op is null

  15. HelpDelete boolean helpdelete(DFlag op){ boolean result; result = op.p.update.CAS(<op.pflag, op.pstamp>, <op.pflag, 3>); if(result = true){ helpmarked(op); return true; } else // help p … CAS(<op.pflag, op.pstamp>, <op, 3>);

  16. Test #3 No error detected  insert(10) delete(10) || insert(20)

More Related