/
ObstructionFree Synchronization DoubleEnded Queues as an Example Maurice Herlihy Computer ObstructionFree Synchronization DoubleEnded Queues as an Example Maurice Herlihy Computer

ObstructionFree Synchronization DoubleEnded Queues as an Example Maurice Herlihy Computer - PDF document

cheryl-pisano
cheryl-pisano . @cheryl-pisano
Follow
490 views
Uploaded On 2014-12-16

ObstructionFree Synchronization DoubleEnded Queues as an Example Maurice Herlihy Computer - PPT Presentation

This property is strong enough to avoid the problems associ ated with locks but it is weaker than previous nonblocking propertiesspeci64257cally lockfreedom and waitfreedom allowing greater 64258exibility in the design of ef64257cient imple mentatio ID: 25064

This property strong

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "ObstructionFree Synchronization DoubleEn..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Obstruction-FreeSynchronization:Double-EndedQueuesasanExampleMauriceHerlihyComputerScienceDepartmentBrownUniversity,Box1910Providence,RI02912VictorLuchangcoMarkMoirSunMicrosystemsLaboratories1NetworkDrive,UBUR02-311Burlington,MA01803Weintroduce,anewnonblockingpropertyforshareddatastructureimplementations.Thispropertyisstrongenoughtoavoidtheproblemsassoci- twoormoreconßictingthreadsareexecutingconcurrently.Themostradicalwayinwhichourapproachofim-plementingobstruction-freealgorithmsdiffersfromtheusualapproachofimplementingtheirlock-freeandwait-freecounterpartsisthatwethinkthatensuringprogressshouldbeconsideredaproblemofengineering,notofmath-ematics.WebelievethatcomminglingcorrectnessandprogresshasinadvertentlyresultedinunnecessarilyinefÞ-cientandconceptuallycomplexalgorithms,creatingabar-riertowidespreadacceptanceofnonblockingformsofsyn-chronization.Webelievethatacleanseparationbetweenthetwoconcernspromisessimpler,moreefÞcient,andmoreeffectivealgorithms.Tosupportourcase,wehaveimplementedseveralobstruction-freeshareddatastructuresthatdisplayproper-tiesnotyetachievedbycomparablelock-freeimplementa-tions.Inthispaper,wepresenttwoobstruction-freedouble-endedqueue(deque)implementations.Elsewhere[11],wedescribeasoftwaretransactionalmemoryimplementationusedtoconstructanobstruction-freered-blacktree[5].Toourknowledge,therearenolock-freeimplementationsofanydatastructureascomplicatedasared-blacktree.Asanaside,wenotethatthereisnoÒobstruction-freehierarchyÓcomparabletotheÒwait-freeconsensushierar-chyÓ:Onecansolveobstruction-freeconsensususingonlyread/writeregistersbyderandomizingrandomizedwait-freeconsensusalgorithmssuchastheonein[4].Becauseobstruction-freedomdoesnotguaranteeprogressinthepresenceofcontention,weneedtopro-videsomemechanismtoreducethecontentionsothatprogressisachieved.However,lock-freeandwait-freeimplementationstypicallyalsorequiresuchmechanismstogetsatisfactoryperformance.Wecanusethesesamemechanismswithobstruction-freeimplementations,aswediscussbelow.Becauseobstruction-freedomguaranteessafetyregardlessofthecontention,wecanchangemecha-nisms,evendynamically,withoutchangingtheunderlyingnonblockingimplementation.Onesimpleandwell-knownmethodtoreducecon-tentionisforoperationstoÒbackoffÓwhentheyencounterinterferencebywaitingforsometimebeforeretrying.Var-iouschoicesforhowlongtowaitarepossible;randomizedexponentialbackoffisoneschemethatiseffectiveinmanycontexts.Otherapproachestoreducingcontentionincludequeuingandtimestampingapproaches,inwhichthreadsagreeamongstthemselvestoÒwaitÓforeachothertoÞn-ish.Whilesimplisticapplicationsoftheseideaswouldgiverisetosomeofthesameproblemsthattheuseoflocksdoes,wehavemuchmorefreedomindesigningsophisticatedap-proachesforcontentioncontrolthanwhenusinglocks,be-causecorrectnessisnotjeopardizedbyinterruptinganoper-ationatanytimeandallowinganotheroperationtocontinueexecution.Infact,itispossibletodesigncontentionmanage-mentmechanismsthatguaranteeprogresstoeveryoper-ationthattakesenoughsteps,providedthesystemsatis-Þessomeveryweak(andreasonable)assumptions.Thus,thestrongprogresspropertiesofwait-freeimplementationscanbeachievedinpracticebycombiningobstruction-freeimplementationswithappropriatecontentionmanagers.Inscenariosinwhichcontentionbetweenoperationsisrare,wewillbeneÞtfromthesimpleandefÞcientobstruction-freedesigns;themoreheavy-weightcontentionresolutionmechanismswillrarelybeinvoked.Incontrast,inmostlock-freeandwait-freeimplementations,themechanismsthatareusedtoensuretherespectiveprogresspropertiesim-posesigniÞcantoverheadevenintheabsenceofcontentionAstudyoftheperformanceofvariouscontentionman-agersinpractice,andtradeoffsbetweensystemassump-tions,progressguaranteesandperformanceisbeyondthescopeofthispaper.Insomecontexts,explicitcontentionreductionmecha-nismsmayevenbeunnecessary.Forexample,inaunipro-cessorwherethreadsarescheduledbytimeslice,relativelyshortobstruction-freeoperationswillbeguaranteedtorunaloneforlongenoughtocomplete.Similarly,inpriority-scheduleduniprocessors,anoperationrunsinisolationun-lessitispreemptedbyahigherpriorityoperation.(Asanaside,ithasbeenshownpreviouslythattheconsensushier-archycollapsesinsuchsystems[2,17].However,inthesecorrectness,aswellasprogress,dependsonthesys-temassumptions.)InSection2,wediscusspreviousworkonnonblockingdeques.Section3presentsasimpleobstruction-freedequeimplementationonalineararray,andSection4extendsthisalgorithmtocirculararrays.Adetailedformalprooffortheextendedalgorithmisgiveninafullversionofthepaper[10].WeconcludeinSection5.2.RelatedWorkonNonblockingDequesInthissection,webrießysummarizerelatedworkonnonblockingdeques.Double-endedqueues(deques)areformallydeÞnedin[6,13].Informally,dequesgeneralizeFIFOqueuesandLIFOstacksbysupportingasequenceofvaluesandoperationsforadding(pushing)avaluetoorre-moving(popping)avaluefromeitherend.Thus,imple-mentingashareddequecombinesalloftheintricaciesofimplementingqueuesandstacks.etal.proposedalimited-functionalityCAS-basedlock-freedequeimplementation[3].Theirdequeallowsonlyoneprocesstoaccessoneend,andonlypopoperationstobedoneontheother.Thus,theydidnotfacethedifÞcultproblemofconcurrentpushesandpopsonthesameendofthedeque.TheyfurthersimpliÞedtheproblembyallow-ingsomeconcurrentoperationstosimplyabortandreport failure.Greenwaldproposedtwolock-freedequeimplementa-tions[7].BothimplementationsdependonahardwareDCAS(doublecompare-and-swap)instruction,whichisnotwidelysupportedinpractice,andoneofthemdoesnotsupportnoninterferingconcurrentoperationsatoppo-siteendsofthedeque.Variousmembersofourgrouphavealsoproposedseverallock-freedequeimplementationsthatdependonDCAS[1,6,14].MichaelproposedasimpleandefÞcientlock-free,CAS-baseddequeimplementation[15].However,thetechniqueusedbythisalgorithmfundamentallycausesalloperationstointerferewitheachother.Therefore,itoffersnoin-sightintodesigningscalablenonblockingdatastructuresinwhichnoninterferingoperationscanproceedinparallel.3.Obstruction-FreeDequeImplementationInthissectionwepresentourarray-basedobstruction-freedequeimplementation.Thisalgorithmisextremelysimple,butitisnotarealdequeinthesensethatitdoesnotreallygeneralizequeues:ifweonlypushononeendandpopfromtheother,wewillexhaustthespaceinthearrayandwillnotbeabletopushanymoreitems.Inthenextsection,weshowhowtoextendthealgorithmtoÒwraparoundÓinthearrayinordertoovercomethisproblem.Thedatadeclarationsandright-sidepushandpopop-erationsareshowninFigure1;theleft-sideoperationsaresymmetricwiththeright-sideones.WeassumetheexistenceoftwospecialÒnullÓvalues(leftnullandrightnull)thatareneverpushedontothedeque.Weuseanarraytostorethecurrentstateofthedeque.Thedequecancontainuptoval-ues,andthearrayisofsizetoaccommodatealeft-mostlocationthatalwayscontainsandarightmostlo-cationthatalwayscontains.(Theseextralocationsarenotstrictlynecessary,buttheysimplifythecode.)Oural-gorithmmaintainstheinvariantthatthesequenceofval-uesinA[0].val..A[MAX+1].valalwaysconsistsofatleastone,followedbyzeroormoredatavalues,fol-lowedbyatleastone.ThearraycanbeinitializedanywaythatsatisÞesthisinvariant.Tosimplifyourpresenta-tion,weassumetheexistenceofafunctionwhichacceptsaparameterandreturnsanarrayindex.Theintuitionisthatthisfunctionattemptstoreturntheindexoftheleftmostvalueinwheninvokedwiththeparameter,andattemptstoreturnthein-dexoftherightmostvalueinwheninvokedwiththe.Thealgorithmislinearizable[12]evenifcanbeincorrect(weassumethatitatleastalwaysreturnsavaluebetween,inclusive,whenin-vokedwiththeparameterandalwaysreturnsavalue,inclusive,wheninvokedwiththepa-;clearlyitistrivialtoimplementafunctionthatsatisÞesthisproperty).Strongerpropertiesoftheor-aclearerequiredtoproveobstruction-freedom;wediscussthesepropertiesandhowtheycanbeachievedlater.Asexplainedinmoredetailbelow,weattachversionnumberstoeachvalueinordertopreventconcurrentop-erationsthatpotentiallyinterferefromdoingso.Thever-sionnumbersareupdatedatomicallywiththevaluesusingacompare-and-swap(CAS)instruction.Asusualwithver-sionnumbers,weassumethatsufÞcientbitsareallocatedfortheversionnumberstoensurethattheycannotÒwraparoundÓduringtheshortintervalinwhichoneprocessexe-cutesasingleiterationofashortloopinouralgorithm.Thereasonourobstruction-freedequeimplementationissosimple(andthereasonwebelieveobstruction-freeim-plementationsingeneralwillbesigniÞcantlysimplerthantheirlock-freeandwait-freecounterparts)isthatthereisnoprogressrequirementwhenanyinterferenceisdetected.Thus,providedwemaintainbasicinvariants,wecansim-plyretrywhenwedetectinterference.Inourdequeimple-mentation,datavaluesarechangedonlyatthelinearizationpointofsuccessfulpushandpopoperations.Topreventconcurrentoperationsfrominterferingwitheachother,weincrementversionnumbersofadjacentlocations(withoutchangingtheirassociateddatavalues).Asaresultofthistechnique,twoconcurrentoperationscaneachcausetheothertoretry:thisexplainswhyourimplementationissosimple,andalsowhyitisnotlock-free.Tomakethisideamoreconcrete,wedescribeourimplementationinmorede-tailbelow.Thebasicideabehindouralgorithmisthataoperationchangestheleftmostvalue,andaoperationchangestherightmostdatavaluetoandreturnsthatvalue(theleft-sideop-erationsaresymmetric,sowedonotdiscussthemfurtherexceptwhendealingwithinteractionsbetweenleft-andright-sideoperations).Eachthatsuccessfullypushesadatavalue(asopposedtoreturn-ingÒfullÓ)islinearizedtothepointatwhichitchangesanvalueto.Similarly,eachoperationthatreturnsavalue(asopposedtoreturningÒemptyÓ)islin-earizedtothepointatwhichitchangestheÞeldofsomearraylocationfrom.Furthermore,theÞeldofanarraylocationdoesnotchangeunlessanoper-ationislinearizedasdiscussedabove.TheoperationreturnsÒfullÓonlyifitobservesanon-valueA[MAX].val.Giventheseobservations,itiseasytoseethatouralgorithmislinearizableifwebelievethefollowing instructiontakesthreeparameters:anaddressanexpectedvalue,andanewvalue.Ifthevaluecurrentlystoredatmatchestheexpectedvalue,thenCASstoresthenewvalueataddressandreturns;wesaythattheCASinthiscase.Otherwise,CASreturnsanddoesnotmodifythememory;wesaythattheCASinthiscase. typeelement=recordval:valtype;ctr:intendA:array[0..MAX+1]ofelementinitiallythereissomekin[0,MAX]suchthatA[i]=&#xLN,0;foralliin[0,k]andA[i]=&#xRN,0;foralliin[k+1,MAX+1].rightpush(v)//visnotRNorLNRH0:while(true){RH1:k:=oracle(right);//findindexofleftmostRNRH2:prev:=A[k-1];//read(supposed)rightmostnon-RNvalueRH3:cur:=A[k];//read(supposed)leftmostRNvalueRH4:if(prev.val!=RNandcur.val=RN){//oracleisrightRH5:if(k=MAX+1)return"full";//A[MAX]!=RNRH6:if&#xprev;&#x.val;&#x,pre;&#xv.ct;&#xr+10;CAS(&A[k-1],prev,)//trytobumpupprev.ctrRH7:if&#xv,cu;&#xr.ct;&#xr+10;CAS(&A[k],cur,)//trytopushnewvalueRH8:return"ok";//itworked!}//endif(prev.val!=RNandcur.val=RN)}//endwhileRP0:while(true){//keeptryingtillreturnvaloremptyRP1:k:=oracle(right);//findindexofleftmostRNRP2:cur:=A[k-1];//read(supposed)valuetobepoppedRP3:next:=A[k];//read(supposed)leftmostRNRP4:if(cur.val!=RNandnext.val=RN){//oracleisrightRP5:if(cur.val=LNandA[k-1]=cur)";//adjacentLNandRNRP6:return"emptyRP7:if&#xRN,n;xt.; tr+;ကCAS(&A[k],next,)//trytobumpupnext.ctrRP8:if&#xRN,c;&#xur.c;&#xtr+1;CAS(&A[k-1],cur,)//trytoremovevalueRP9:returncur.val//itworked;returnremovedvalue}//endif(cur.val!=RNandnext.val=RN)}//endwhileFigure1.Obstruction-freedequeimplementation:Datadeclarationsandright-sideoperationsthreeclaims(andtheirsymmetriccounterparts):AtthemomentthatlineofaoperationsuccessfullychangesA[k].valforsomeA[k-1].valcontainsanon-value(i.e.,eitheradatavalueorAtthemomentthatlineoftheoper-ationsuccessfullychangesA[k-1].valforsomefromsomevalueA[k].valIfaoperationreturnsÒemptyÓ,thenatthemomentitexecutedlineA[k].val=RNA[k-1].val=LNheldforsomeUsingtheaboveobservationsandclaims,aproofbysimulationtoanabstractdequeinanarrayofsizestraightforward.Belowwebrießyexplainthesynchroniza-tiontechniquesthatweusetoensurethattheaboveclaimshold.Thetechniquesallexploittheversionnumbersinthearraylocations.Theemptycase(thethirdclaimabove)isthesimplest:returnsÒemptyÓonlyifitreadsthesamevaluealueatlines.BecauseeveryCASthatmodiÞesanarraylocationincrementsthatlocationÕsversionnumber,itfollowsthatthatmaintainedthesamevaluethroughoutthisinterval(recallourassumptionaboutversionnumbersnotwrappingaround).Thus,inpar-ticular,A[k-1].valatthemomentthatlineA[k].valThetechniquesusedtoguaranteetheothertwoclaimsareessentiallythesame,soweexplainonlytheÞrstone.Thebasicideaistocheckthattheneighbouringlocationlocation)containstheappropriatevalue(lineseealsoline),andtoincrementitsversionnumber(withoutchangingitsvalue;line)betweenreadingthelocationtobechanged(line)andattemptingtochangeit(line).Ifanyoftheattemptstochangealocationfail,thenwehaveencounteredsomeinterference,sowecansimplyrestart.Otherwise,itcanbeshowneasilythattheneighbouringlocationdidnotchangeto thetimeitwasread(line)andthetimethelocationtobechangedischanged(line).ThereasonisthatoperationÑtheonlyoperationthatchangeslocationstoÑthatwasattemptingtochangetheneigh-bouringlocationtowouldincrementtheversionnumberofthelocationtheoperationistryingtomod-ify,sooneoftheoperationswouldcausetheothertoretry.3.1.OracleImplementationsTherequirementsforthefunctionassumedintheprevioussectionarequiteweak,andthereforeanum-berofimplementationsarepossible.WeÞrstdescribetherequirements,andthenoutlinesomepossibleimplementa-tions.Forlinearizability,theonlyrequirementontheoracleisthatitalwaysreturnsanindexfromtheappropriaterangedependingonitsparameterasstatedearlier;satisfyingthisrequirementistrivial.However,toguaranteeobstruction-freedom,werequirethattheoracleiseventuallyaccurateifrepeatedlyinvokedintheabsenceofinterference.ByÒac-curateÓ,wemeanthatitreturnstheindexoftheleftmostwheninvokedwith,andtheindexoftheright-wheninvokedwith.Itiseasytoseethatifanyoftheoperationsexecutesanentireloopiterationinisolation,andthefunctionreturnstheindexspec-iÞedabove,thentheoperationcompletesinthatiteration.Becausetheoraclehasnoobligation(exceptforthetrivialrangeconstraint)inthecasethatitencountersinterference,wehaveplentyofßexibilityinimplementingit.Onesim-pleandcorrectimplementationistosearchthearraylin-earlyfromoneendlookingfortheappropriatevalue.De-pendingonthemaximumdequesize,however,thissolutionmightbeveryinefÞcient.Onecanimagineseveralalterna-tivestoavoidthisexhaustivesearch.Forexample,wecanmaintainÒhintsÓfortheleftandrightends,withthegoalofkeepingthehintsapproximatelyaccurate;thenwecouldreadthosehints,andsearchfromtheindicatedarrayposi-tion(weÕllalwaysbeabletotellwhichdirectiontosearchusingthevaluesweread).Becausethesehintsdonothavetobeperfectlyaccurateatalltimes,wecanchoosevariouswaystoupdatethem.Forexample,ifweuseCAStoup-datethehints,wecanpreventslowprocessesfromwritingout-of-datevaluestohints,andthereforekeephintsalmostaccurateallthetime.Itmayalsobeusefultoloosentheaccuracyofthehints,therebysynchronizingonthemlessoften.Inparticular,wemightconsideronlyupdatingthehintwhenitispointingtoalocationthatresidesinadif-ferentcachelinethanthelocationthatreallycontainstheforexample,asinthiscasethecostoftheinac-curatehintwouldbemuchhigher.4.ExtensiontoCircularArraysInthissection,weshowhowtoextendthealgorithmintheprevioussectiontoallowthedequetoÒwraparoundÓthearray,sothatthearrayappearstobecircular.Inotherwords,ords,isÒimmediatelytotherightÓofof.Asbefore,wemaintainatleasttwonullentriesinthearray:weusethearrayarrayforadequewithatmostelements.Thearraycanbeinitializedarbitrarilypro-videditsatisÞesthemaininvariantforthealgorithm,statedbelow.Oneoptionistousetheinitialconditionsforthealgorithmintheprevioussection.Wenowdescribethenewaspectsofthealgorithm.Codefortheright-sideoperationsofthewrap-arounddequeim-plementationareshowninFigure2.Theleft-sideopera-tionsaresymmetric,andwedonotdiscussthemfurtherexceptastheyinteractwiththeright-sideoperations.AllarithmeticonarrayindicesisdonemoduloTherearetwomaindifferencesbetweenthisalgorithmandtheoneintheprevioussection.First,itismoredifÞculttotellwhetherthedequeisfull;wemustdeterminethatthereareexactlytwonullentries.Second,operationsmayencountervaluesastheyÒconsumeÓthevaluesandwraparoundthearray(similarly,operationsmayencountervalues).Wehandlethissec-ondproblembyenablingaoperationtoÒcon-vertÓvaluesintovalues.Thisconversionusesanextranullvalue,whichwedenote,forÒdummynullÓ.WeassumethatareneverpushedontotheBecausethearrayiscircular,thealgorithmmaintainsthefollowinginvariantsinsteadofthesimplerinvariantmain-tainedbythealgorithmintheprevioussection:Allnullvaluesareinacontiguoussequenceofloca-tionsinthearray.(Recallthatthearrayiscircular,sothesequencecanwraparoundthearray.)Thesequenceofnullvaluesconsistsofzeroormorevalues,followedbyzerooronevalue,followedbyzeroormorevalues.Thereareatleasttwodifferenttypesofnullvaluesinthesequenceofnullvalues.Thus,thereisalwaysatleastoneentry,andatleastoneentry.Insteadofinvokingdirectly,thepushandpopoperationsinvokeanewauxiliaryprocedure,.Inadditiontoanarrayindex,thecontentsitlastsawinnandA[k]respectively.Itright.val=RNleft.val!=RNThus,ifitrunsinisolation,waysreturnsthecorrectindex,togetherwithcontentsofthe /*Returnsk,left,right,whereleft=A[k-1]atsometimet,andright=A[k]atsometimet’�tduringtheexecution,withleft.val!=RNandright.val=RN.RO0:while(true){RO1:k:=oracle(right);RO2:left:=A[k-1];//orderimportantforcheckRO3:right:=A[k];//foremptyinrightpopRO4:if(right.val=RNandleft.val!=RN)//correctoracleRO5:returnk,left,right;RO6:if(right.val=DNand!(left.valin{RN,DN}))//correctoracle,butnoRNsRO7:ifCAS(&A[k-1],left,&#xleft;&#x.val;&#x,lef;&#xt.ct;&#xr+10;)RO8:ifCAS(&A[k],right,&#xRN,r;&#xight;&#x.ctr;&#x+100;)//DN&#xRN,r;&#xight;&#x.ctr;&#x+100;-RNRO9:return&#xleft;&#x.val;&#x,lef;&#xt.ct;&#xr+10;&#xRN,r;&#xight;&#x.ctr;&#x+100;k,}//endwhilerightpush(v)//!(vin{LN,RN,DN})RH0:while(true){RH1:k,prev,cur:=rightcheckedoracle();//cur.val=RNandprev.val!=RNRH2:next:=A[k+1];RH3:if(next.val=RN)RH4:ifCAS(&A[k-1],prev,&#xprev;&#x.val;&#x,-58;.80;prev.ctr+1)RH5:ifCAS(&A[k],cur,&#xv,-5;ˆ.8;cur.ctr+1)//RN&#xv,-5;ˆ.8;-vRH6:return"ok";RH7:if(next.val=LN)RH8:ifCAS(&A[k],cur,&#xRN,-;ֈ.;耀cur.ctr+1)RH9:CAS(&A[k+1],next, N,-;ֈ.;耀next.ctr+1);//LN N,-;ֈ.;耀-DNRH10:if(next.val=DN){RH11:nextnext:=A[k+2];RH12:if!(nextnext.valin{RN,LN,DN})RH13:if(A[k-1]=prev)RH14:if(A[k]=cur)return"full";RH15:if(nextnext.val=LN)RH16:ifCAS(&A[k+2],nextnext,&#xnext;&#xnext;&#x.val;&#x,nex;&#xtnex;&#xt.ct;&#xr+10;)RH17:CAS(&A[k+1],next,&#xRN,-;ֈ.;耀next.ctr+1);//DN&#xRN,-;ֈ.;耀-RN}//endif(next.val=DN)}//endwhileRP0:while(true){RP1:k,cur,next:=rightcheckedoracle();//next.val=RNandcur.val!=RNRP2:if(cur.valin{LN,DN}andA[k-1]=cur)//dependsonorderofRO2&RO3.RP3:return"empty";RP4:if&#xRN,n;xt.; tr+;ကCAS(&A[k],next,)RP5:if&#xRN,c;&#xur.c;&#xtr+1;CAS(&A[k-1],cur,)//v-&#xRN,c;&#xur.c;&#xtr+1;RNRP6:returncur.val;}//endwhileFigure2.Wraparounddequeimplementation:Right-sideoperations. appropriatearrayentriesthatprovethattheindexiscorrect.Ifnoentryexists,thenbythethirdinvariantabove,thereisaentryandanattemptstoconverttheintoanbeforereturning.Otherthancallinginsteadof(whichalsoeliminatestheneedtoreadandcheckthevaluesagain),theonlychangeintheoperationisthat,incheckingwhetherthedequeisempty,maybeeither,becausetheremaybenoBecausethearrayiscircular,acannotdeterminewhetherthearrayisfullbycheckingwhetherthereturnedindexisattheendofthearray.In-stead,itensuresthatthereisspaceinthearraybycheckingA[k+1].val=RN.Inthatcase,bythethirdinvari-antabove,thereareatleasttwonullentriesotherthanthan(whichalsocontains),sothedequeisnotfull.Other-Þrstattemptstoconvertertintoanentry.Wediscusshowthisconversionisaccomplishedbelow.WhenaoperationÞndsonlyonetry,ittriestoconvertthenextnullentryÑweknowthereisonebythethirdinvariantaboveÑintoan.Ifthenextnullentryisanentry,thenÞrstattemptstoconvertitintoaentry.Whendoingthis,checksthatcur.val=RN,whichensuresthereisatmostoneentry,asrequiredbythesecondinvariantabove.Ifthenextnullentryisaentry,willtrytoconvertitintoanentry,butonlyiftheentrytotherightoftheonebeingconverted(theisanentry.Inthiscase,itÞrstincrementstheversionnumberoftheentry,ensuringthefailureofanyoperationtryingtopushavalueintothatentry.Iftheentryisadequevalue,thentheoperationcheckswhethertherightendofthedequeisstillat(byrereadingrereadingandA[k]),andifso,thedequeisfull.Ifnot,orifthetryiseitheranentry,thensomeotheroperationisconcurrentwiththe,andtheoperationretries.Assumingtheinvariantsabove,itiseasytoseethatthisnewalgorithmislinearizableinexactlythesamewayasthealgorithmintheprevioussection,exceptthataoperationthatreturnsÒfullÓlinearizesatthepointthatisread(line).BecausewesubsequentlyconÞrm(line)thatthatandA[k]havenotchangedsincetheywerelastread,weknowthedequeextendsfromfromtoA[k-1](withA[k-1]asitsrightmostvalue),sothatthatandA[k+1]aretheonlynonnullentries,andthus,thedequeisfull.Provingthattheinvariantsabovearemaintainedbythenewalgorithmisnontrivial,andwedeferacompleteprooftothefullpaper[10].ThemaindifÞcultyisverifyingthatwhenaactuallypushesthenewvalueontothedeque(line),eithertheentryisanentry,oritisaentryandtheentryisanentry.Thisisnecessarytoensurethatafterthepush,therearestillatleasttwonullentries,oneofwhichisanentry.Onekeytotheproofistonotethatthevalueofanentryischangedonlybylines,andtheircounterpartsintheleft-sideoperations.Furthermore,theselinesonlychangeanentryiftheentryhasnotchangedsinceitwasmostrecentlyread.TheselinesareannotatedinFigure2withhowtheychangethevalueoftheentry.TimecomplexityTheobviousmeasureofthetimecom-plexityofanobstruction-freealgorithm(withoutregardtotheparticularcontentionmanagerandsystemassumptions)istheworst-casenumberofstepsthatanoperationmusttakeinisolationinordertobeguaranteedtocomplete.Forouralgorithms,thisisaconstantplustheobstruction-freetimecomplexityoftheparticularoracleimplementa-tionused.5.ConcludingRemarksWehaveintroducedobstruction-freedomÑanewnon-blockingconditionforshareddatastructuresthatweakenstheprogressrequirementsoftraditionalnonblockingcondi-tions,andasaresultadmitssolutionsthataresigniÞcantlysimplerandmoreefÞcientinthetypicalcaseoflowcon-tention.Wehavedemonstratedthemeritsofobstruction-freedombyshowinghowtoimplementanobstruction-freedouble-endedqueuethathasbetterpropertiesthananypre-viousnonblockingdequeimplementationofwhichweareaware.Wearealsoexploringotherobstruction-freeal-gorithmsandtechniques.Basedonourprogresstodate,weareconvincedthatobstruction-freedomisasigniÞcantbreakthroughinthesearchforscalableandefÞcientnon-blockingdatastructures.Apartfromongoingworkonotherobstruction-freealgorithms,animportantpartofourworkisininvestigatingtheuseofvariousmechanismstoman-agecontentioninordertoallowobstruction-freeimple-mentationstomakeprogressevenundercontention.Therehasbeenmuchworkonsimilarissues,forexampleinthecontextofdatabases.Weareworkingonevaluatingex-istingandnewschemesforthispurpose.Thebeautyofobstruction-freedomisthatwecanmodifyandexperimentwiththecontentionmanagementmechanismswithoutneed-ingtomodify(andthereforereverify)theunderlyingnon-blockingalgorithm.Incontrast,workondifferentmech-anismsforguaranteeingprogressinthecontextoflock-freeandwait-freealgorithmshasbeenhamperedbythefactthatmodiÞcationstotheÒhelpingÓmechanismshasgener-allyrequiredtheproofsfortheentirealgorithmtobedone References[1]O.Agesen,D.Detlefs,C.Flood,A.Garthwaite,P.Martin,M.Moir,N.Shavit,andG.Steele.DCAS-basedconcurrentTheoryofComputingSystems,2003.Toappear.ApreliminaryversionappearedintheProceedingsofthe12thACMSymposiumonParallelAlgorithmsandArchitectures.[2]J.AndersonandM.Moir.Wait-freesynchronizationinmultiprogrammedsystems:Integratingpriorty-basedandquantum-basedscheduling.InProceedingsofthe18thAn-nualACMSymposiumonPrinciplesofDistributedComput-,pages123Ð132,1999.[3]N.S.Arora,B.Blumofe,andC.G.Plaxton.Threadschedul-ingformultiprogrammedmultiprocessors.InProceedingsofthe10thAnnualACMSymposiumonParallelAlgorithmsandArchitectures,pages119Ð129,1998.[4]J.AspnesandM.Herlihy.Fastrandomizedconsensusus-ingsharedmemory.JournalofAlgorithms,11(3):441Ð461,[5]T.H.Cormen,C.E.Leiserson,andR.L.Rivest.Introduc-tiontoAlgorthms.McGrawHill,1stedition,1989.[6]D.Detlefs,C.Flood,A.Garthwaite,P.Martin,N.Shavit,andG.Steele.EvenbetterDCAS-basedconcurrentdeques.Proceedingsofthe14thInternationalConferenceonDis-tributedComputing,pages59Ð73,2000.[7]M.Greenwald.Non-BlockingSynchronizationandSystem.PhDthesis,StanfordUniversityTechnicalReportSTAN-CS-TR-99-1624,PaloAlto,CA,August1999.[8]M.GreenwaldandD.Cheriton.Thesynergybetweennon-blockingsynchronizationandoperatingsystemstructure.InProceedingsoftheSecondSymposiumonOperatingSystemDesignandImplementation,pages123Ð136,1996.[9]M.Herlihy.Amethodologyforimplementinghighlycon-currentdataobjects.ACMTransactionsonProgrammingLanguagesandSystems,15(5):745Ð770,1993.[10]M.Herlihy,V.Luchangco,andM.Moir.Obstruction-freesynchronization:Double-endedqueuesasanexample.Inpreparation,2003.[11]M.Herlihy,V.Luchangco,andM.Moir.Softwaretransac-tionalmemoryforsupportingdynamicdatastructures.Inpreparation,2003.[12]M.HerlihyandJ.Wing.Linearizability:Acorrectnesscon-ditionforconcurrentobjects.ACMTransactionsonPro-grammingLanguagesandSystems,12(3):463Ð492,1990.[13]D.E.Knuth.TheArtofComputerProgramming:Funda-mentalAlgorithms.Addison-Wesley,1968.[14]P.Martin,M.Moir,andG.Steele.DCAS-basedconcurrentdequessupportingbulkallocation.TechnicalReportTR-2002-111,SunMicrosystemsLaboratories,2002.[15]M.Michael.Dynamiclock-freedequesusingsingle-address,double-wordcas.Technicalreport,IBMTJWatsonResearchCenter,January2002.[16]M.MichaelandM.Scott.Simple,fast,andpracticalnon-blockingandblockingconcurrentqueuealgorithms.InPro-ceedingsofthe15thAnnualACMSymposiumonthePrinci-plesofDistributedComputing,pages267Ð276,1996.[17]S.Ramamurthy,M.Moir,andJ.Anderson.Real-timeobjectsharingwithminimalsystemsupport.InProceedingsofthe15thAnnualACMSymposiumonPrinciplesofDistributed,pages233Ð242,1996.