model checking lock-free binary search tree presented by joanna helga

16
Model Checking Model Checking Lock-Free Binary Search Lock-Free Binary Search Tree Tree Presented by Joanna Helga

Upload: dominick-gardner

Post on 17-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

  • Model CheckingLock-Free Binary Search TreePresented by Joanna Helga

  • Leaf Oriented BSTImplements Dictionary ADTOperations: Find, Insert, Delete

    Real keys are stored in leafInternal nodes stores dummy keys and exactly has 2 childrenLeaves stores only a keyBADCGEH

  • Node StructureNodeLeafkey : int2

  • InsertInsert(E)search for locationcreate Leaf(E)create Internal(max(E,D))point its left and right child to D and EFlag Bchange Bs pointer to the new Internal nodeUnflag B

    BDEEBIs parent node clear?

  • DeleteDelete(C)Search Cs locationFlag B (grandparent)Mark D (parent)Change Bs child pointer to Cs siblingUnflag BBDCBDIs parent node clear?Is grandparent node clear?

  • SearchReturn ClassSearchReturnl : Nodep : Nodegp : Nodepupdate : AtomicStampedReferencegpupdate : AtomicStampedReference

  • Helper Node StructureFlagp : Nodel : NodeIFlagnewinternal: NodeDFlaggp : Nodepupdate : AtomicStampedReference

  • CheckingDictionary 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);

  • Test #1d.Insert(mykey);l = d.Find(mykey);assert(l != null);assert(l.key == mykey);assert errornull pointer exception

  • Insert - Detailedgpplsearch locationif (pupdate.stamp = clean) then// try insert hereelse// help gp hereif (pupdate.stamp = clean) then create new node create helper node op p.update.CAS(pupdate, ) if (CAS successful) then // actually modify the BST

  • Insert - Fixedgpplintintif (p.update.stamp = clean) then create new node create helper node op p.update.CAS(, ) if (CAS successful) then // actually modify the BST

  • Test #2null pointer exception

  • Delete - Detailedgpplsearchif (gp.update.stamp != 0)help(gp.update)else if(p.update.stamp != 0)help(p.update)else//try delete// try deletecreate helper node opgp.update.CAS(, )if(CAS successful)// try modify BSTelsehelp(gp.update)

  • Help & HelpMarkedhelp(AtomicStampedReference update){if(update.stamp = 1)//1=iflaghelpinsert(update.reference);else if(update.stamp = 3)//3=markhelpmarked(update.reference);else if(update.stamp = 2)//2=dflag;helpdelete(update.reference);}

    private void helpmarked(DFlag op){// Modify BST}

  • HelpDeleteboolean helpdelete(DFlag op){boolean result;

    result = op.p.update.CAS(, );if(result = true){helpmarked(op);return true;}else// help p CAS(, );

  • Test #3No error detected