Data linkage dynamics with shedding
We study shedding in the setting of data linkage dynamics, a simple model of computation that bears on the use of dynamic data structures in programming. Shedding is complementary to garbage collection. With shedding, each time a link to a data objec…
Authors: J. A. Bergstra, C. A. Middelburg
Data Link age Dynamics with Shedding ⋆ J.A. Bergstra and C.A. Middelburg Informatics Institute, Universit y of Amsterdam Science Park 107, 1098 X G Amsterdam, t he Netherlands J.A.Bergst ra@uva.nl,C.A.M iddelburg@uva.nl Abstract. W e stu d y shed ding in the setting of data link age dynamics, a simple model of computation that b ears on the use of dyn amic data structures in programming. Shedding is complementary to garbage col- lection. With shedding, eac h time a link t o a data ob ject is u p dated by a program, it is determined whether or not the link will possibly b e used once again by the program, and if not the link is automatically remove d. Thus, ev erything is made garbage as soon as it can b e viewed as garbage . By that, th e effectiveness of garbage collection b ecomes maximal. Keywo rds: data link age dynamics, shed d ing, forecasting service. 1998 ACM Comput ing Classification: D.3.3, D.4.2, F.1.1, F.3. 3. 1 In tro duct ion This pap er is a seq uel to [9 ]. In that pap er, we pres e n ted an alge br a, called data link a ge algebr a, o f w hich the elements are intended for mo delling the sta tes of computations in which dynamic data structures a re inv olved. W e also pr esented a simple model of computation, called data link age dy na mics, in which states of computations ar e mo delled as elements of da ta link age alge br a and state changes take pla ce by means of certain actio ns. Data link age dynamics includes the fol- lowing features to reclaim ga rbage: full ga rbage co llection, restricted g arbag e collection (as if reference counts are used), safe disposal of p otential garbage, and unsafe dispo s al of p otential garbag e. In the curre nt paper, we add shedding to the features of data link a ge dy- namics. This feature is complementary to the garba ge collection featur e s of data link a ge dynamics. Roughly sp eak ing , shedding works as follows: each time a link to a da ta ob ject is up dated by a progr am, it is determined whether o r not the link will p ossibly b e used once again by the pro gram, and if not the link is au- tomatically removed. In this wa y , everything is made ga rbage as so on a s it can be taken for garbage. The p oint o f shedding is that by this, the effectiveness of garbag e collection b ecomes maximal. In the sixties of the previous century , when the first lis t-pro cessing lang uages came up, three basic ga rbage collection techniques hav e b een pr op osed: reference ⋆ This researc h has b een partly carried out in the framew ork of the Jacquard-p ro ject Symbiosis , whic h is funded b y the Netherlands Organisation for Scientific Research (NWO). counting (see e.g. [15, 12]), marking (see e.g. [21, 24]), and cop ying (see e.g. [22, 14]). The ga rbage collection techniques that hav e b een pro p o sed in the seven ties and eighties of the pre v ious century are mainly incr e men tal and par allel v ariants of the three basic techniques (see e.g . [4, 20] and [28, 19, 13], resp ectively), which are int ended to avoid substantial interruption due to garbag e co lle ction, and conserv ative and tag-free v ariants o f the three basic techniques (see e.g. [11] and [2 , 16], resp ectively), which a r e intended to p erform garba ge collec tio n mor e efficient. All the gar bage collection techniques prop osed in those times c o llect only data ob jects that a re no longer rea chable b y a ser ies of links. In the next paragr aph, we will use the term “sta ndard garbag e collectio n techn iques” to refer to this group of ga rbage collection tec hniques. Owing to the g rowing use of dynamic data str uctures in pro gramming, the effectiveness of garbag e collection techniques b ecomes increas ingly mo re impor - tant since the nineties o f the prev ious century . It has b een confirmed by recent empirical studies that standard garbag e colle ction techniques actually leave a lot of ga rbage unco llected (see e.g . [25, 26, 17]). F or the greater part, re c ent ly prop osed garba ge collection techniques that are int ended to b e mor e effective than standa rd gar bage colle c tio n techniques tur n out to make us e of approxi- mations of shedding. The approximations a re o btained by means of information ab out future uses of links co ming from static progr am a nalysis. The informatio n is either direc tly provided to an adapted standar d garba ge c ollector (see e.g. [1]) or used to tra nsform the pr ogra m in question such that data o b jects bec o me unreachable a s so on as some safet y pro pe r ty holds according to the information (see e.g . [27, 18]). In the la tter case, the safety prop erty used differs from one prop osal to a no ther, ca n in all cases b e impr oved by taking into acc ount tha t the num b er of data ob jects that can exist at the sa me time is b ounded, and is in all cases at b est weakly justified b y a pr ecise semantics of the programming language suppo sed to be used. Our study o f shedding aris es from the work o n “nullifying de a d links” pr e- sented in [18]. Tha t work co ncerns the remov al o f links that will not p ossibly be used once aga in by means of static prog ram analys is and progra m transfor- mation. In our study of shedding, differe n t from the study in [18], the semantic effects of the fac t tha t the num b er of data ob jects that c a n exist at the same time is alwa ys b ounded are taken into accoun t. The view is taken that the b ehaviours exhibited by pro grams on execution are threads as co ns idered in basic thread alg ebra. 1 A thread pro ce e ds by p erfor ming actions in a s equential fashion. A thread may p erform an action for the purpo se of interacting with a ser v ice that takes the action a s a co mmand to b e pro cessed. The pro c e ssing of the ac tion results in a state change and a reply . In the s etting of bas ic thread algebra , the use mechanism has b een introduced to a llow for this kind of interaction. The sta te changes and r e plies that result fro m p erfor ming the actions of da ta link ag e dy namics can be achiev ed b y means of a s e rvice. 1 In [7], basic th read algebra is introd uced und er the n ame b asic p olarized pro cess algebra. Prompted by the d evelopment of thread algebra [8], which is a design on top of it, basic p olarized process algebra h as b een renamed to basic thread algebra. 2 In [9], it was expla ined how basic thread algebra can be com bined with data link a ge dynamics by means of the use mechanism in such a wa y that the whole can b e used for studying issues concerning the use of dyna mic data structures in progra mming. F or a clear a pprehension of da ta link age dyna mics as pr e s ented in that pap er, such a combination is not needed. This is different for shedding, bec ause it cannot b e explained without refer ence to progra m be haviours. In the current pap er, we adapt the data link age dynamics services involv ed in the combination describ ed in [9] to explain shedding. F or the adapted data link- age dynamics ser vices, shedding happ ens to b e a ma tter close to reflectio n on themselves. Moreover, the a dapted data link age dynamics services are s ervices of whic h the state ch ang es and replies may dep end on how the thread that p er- forms the actions b eing pro c e ssed will pr o ceed. T ha t is wh y we also in tro duce a generaliza tion of the use mechanism to such for ecasting services. This pap er is or ganized as follows. First, we review data link age algebra , data link age dyna mics and basic threa d algebra (Sections 2, 3, a nd 4). Next, we present the use mec hanism for fo recasting services and e x plain ho w basic thread alg e br a can b e combined with da ta link age dyna mics by means of that use mechanism (Sections 5 and 6 ). After that, we introduce the shedding feature and a da pt the data link a ge dynamics services inv olved in the combination de- scrib ed b efor e such that they supp ort s hedding (Sections 7, 8, and 9). Then, w e illustrate shedding by means of some examples (Section 1 0 ). Finally , we make some concluding remarks (Section 11). 2 Data Link age Algebra In this section, we re view the algebra ic theor y DLA (Data Link age Algebra). The elements of the initial alg ebra of DLA can serve for the states of computations in whic h dynamic data structures are in volv ed. In DLA, it is as sumed that a fixed but a rbitrary finite set Sp ot of sp ots , a fixed but arbitr ary finite set Field of fields , a fixed but arbitrar y finite set A tObj of atomic obje cts , and a fixed but arbitrar y finite set Value of values have b een given. DLA has one so rt: the sort DL o f data linkages . T o build terms of sort DL , BT A has the follo wing constants and op e rators: – for each s ∈ Sp ot and a ∈ AtObj , the sp ot link constant s − → a : DL ; – for each a ∈ AtObj a nd f ∈ Field , the p artial field link constant a f − → : DL ; – for each a, b ∈ AtObj and f ∈ Field , the field link constant a f − → b : DL ; – for each a ∈ AtObj a nd n ∈ Value , the value asso ciation constant ( a ) n : DL ; – the empty data linkage co nstant ∅ : DL ; – the binary data linkage c ombination op era tor ⊕ : DL × DL → DL ; – the bina ry data linkage overriding c ombination op erato r ⊕ ′ : DL × DL → DL . T erms of so rt DL are built a s usual. Throughout the pa p er , we as sume that there are infinitely many v aria ble s of sor t DL , including X , Y , Z . W e use infix notation for data link a ge combination a nd data link age overriding combination. 3 Let L and L ′ be close d DLA terms. Then the constants and op era to rs of DLA can be explained as follows: – s − → a is the atomic data link a ge that consists o f a link via sp ot s to atomic ob ject a ; – a f − → is the a tomic data link age that co nsists of a partial link fr om a tomic ob ject a via field f ; – a f − → b is the ato mic data link a ge that cons ists of a link from a tomic o b ject a via field f to atomic ob ject b ; – ( a ) n is the ato mic data link age that consists of a n asso ciatio n of the v alue n with atomic ob ject a ; – ∅ is the data link age that do es not contain any atomic data link age; – L ⊕ L ′ is the union of the data link ages L and L ′ ; – L ⊕ ′ L ′ differs from L ⊕ L ′ as follows: • if L contains sp ot links via sp o t s a nd L ′ contains sp ot links via spot s , then the former links are o verridden by the latter ones; • if L contains partial field links and/or field links from atomic ob ject a via field f and L ′ contains par tial field links and/o r fie ld links from atomic ob ject a via field f , then the fo r mer pa rtial field links and/or field links are ov erridden b y the latter ones; • if L contains v alue asso ciations with atomic ob ject a and L ′ contains v a lue asso cia tions with ato mic o b ject a , then the former v a lue asso cia - tions are o verridden by the la tter ones. The axioms of DLA are given in T able 1 . In this ta ble, s and t s tand for arbitrar y sp ots from Sp ot , f and g stand for a rbitrary fields from Field , a , b , c and d stand for arbitra ry atomic o b jects from AtObj , a nd n and m s ta nd for arbitrar y v alues from V alue . The set B of b asic terms ov er DLA is inductively defined by the fo llowing rules: – ∅ ∈ B ; – if s ∈ Sp ot and a ∈ AtObj , then s − → a ∈ B ; – if a ∈ AtObj and f ∈ Field , then a f − → ∈ B ; – if a, b ∈ AtObj and f ∈ Field , then a f − → b ∈ B ; – if a ∈ AtObj and n ∈ Value , then ( a ) n ∈ B ; – if L 1 , L 2 ∈ B , then L 1 ⊕ L 2 ∈ B . Theorem 1. F or al l close d DLA t erms L , ther e exists a b asic term L ′ ∈ B such that L = L ′ is derivable fr om the axioms of DLA . Pr o of. See Theorem 1 in [9]. W e are o nly interested in the initial mo de l of DLA. W e write DL fo r the set of a ll elements of the initial mo del of DLA. D L consists o f the equiv alence classes of basic terms ov er DLA with resp ect to the equiv a lence induced by the axioms of DLA. In o ther words, mo dulo equiv alence, B is D L . Hencefo r th, we will iden tify basic terms ov er DLA and their equiv alence classes . 4 T able 1. Ax ioms of DLA X ⊕ Y = Y ⊕ X X ⊕ ( Y ⊕ Z ) = ( X ⊕ Y ) ⊕ Z X ⊕ X = X X ⊕ ∅ = X ∅ ⊕ ′ X = X X ⊕ ′ ∅ = X X ⊕ ′ ( Y ⊕ Z ) = ( X ⊕ ′ Y ) ⊕ ( X ⊕ ′ Z ) ( X ⊕ ( s − → a )) ⊕ ′ ( s − → b ) = X ⊕ ′ ( s − → b ) ( X ⊕ ( a f − → )) ⊕ ′ ( a f − → ) = X ⊕ ′ ( a f − → ) ( X ⊕ ( a f − → b )) ⊕ ′ ( a f − → ) = X ⊕ ′ ( a f − → ) ( X ⊕ ( a f − → )) ⊕ ′ ( a f − → b ) = X ⊕ ′ ( a f − → b ) ( X ⊕ ( a f − → b )) ⊕ ′ ( a f − → c ) = X ⊕ ′ ( a f − → c ) ( X ⊕ ( a ) n ) ⊕ ′ ( a ) m = X ⊕ ′ ( a ) m ( X ⊕ ( s − → a )) ⊕ ′ ( t − → b ) = ( X ⊕ ′ ( t − → b )) ⊕ ( s − → a ) if s 6 = t ( X ⊕ ( a f − → )) ⊕ ′ ( s − → b ) = ( X ⊕ ′ ( s − → b )) ⊕ ( a f − → ) ( X ⊕ ( a f − → b )) ⊕ ′ ( s − → c ) = ( X ⊕ ′ ( s − → c )) ⊕ ( a f − → b ) ( X ⊕ ( a ) n ) ⊕ ′ ( s − → b ) = ( X ⊕ ′ ( s − → b )) ⊕ ( a ) n ( X ⊕ ( s − → a )) ⊕ ′ ( b f − → ) = ( X ⊕ ′ ( b f − → )) ⊕ ( s − → a ) ( X ⊕ ( a f − → )) ⊕ ′ ( b g − → ) = ( X ⊕ ′ ( b g − → )) ⊕ ( a f − → ) if a 6 = b ∨ f 6 = g ( X ⊕ ( a f − → b )) ⊕ ′ ( c g − → ) = ( X ⊕ ′ ( c g − → )) ⊕ ( a f − → b ) if a 6 = c ∨ f 6 = g ( X ⊕ ( a ) n ) ⊕ ′ ( b f − → ) = ( X ⊕ ′ ( b f − → )) ⊕ ( a ) n ( X ⊕ ( s − → a )) ⊕ ′ ( b f − → c ) = ( X ⊕ ′ ( b f − → c )) ⊕ ( s − → a ) ( X ⊕ ( a f − → )) ⊕ ′ ( b g − → c ) = ( X ⊕ ′ ( b g − → c )) ⊕ ( a f − → ) if a 6 = b ∨ f 6 = g ( X ⊕ ( a f − → b )) ⊕ ′ ( c g − → d ) = ( X ⊕ ′ ( c g − → d )) ⊕ ( a f − → b ) if a 6 = c ∨ f 6 = g ( X ⊕ ( a ) n ) ⊕ ′ ( b f − → c ) = ( X ⊕ ′ ( b f − → c )) ⊕ ( a ) n ( X ⊕ ( s − → a )) ⊕ ′ ( b ) n = ( X ⊕ ′ ( b ) n ) ⊕ ( s − → a ) ( X ⊕ ( a f − → )) ⊕ ′ ( b ) n = ( X ⊕ ′ ( b ) n ) ⊕ ( a f − → ) ( X ⊕ ( a f − → b )) ⊕ ′ ( c ) n = ( X ⊕ ′ ( c ) n ) ⊕ ( a f − → b ) ( X ⊕ ( a ) n ) ⊕ ′ ( b ) m = ( X ⊕ ′ ( b ) m ) ⊕ ( a ) n if a 6 = b 3 Data Link age Dynamics DLD (Data Link age Dynamics) is a simple mo del of computatio n tha t b ears on the use of dynamic data structur es in progra mming. It comprises states, basic a ctions, and the state changes and r eplies that result from p erforming the basic actions . The states of DLD ar e data link ages. In this section, we give an informal explana tion o f the ba sic actions of DLD to structur e data dynamica lly . The basic actions of DLD to dea l w ith v alues found in dynamica lly structured data, as well as some actions related to recla iming garbag e, are not e x plained. F or a c omprehensive presentation of DLD, the rea der is refer red to [9 ]. 5 Like in DLA , it is assumed tha t a fixed but a rbitrary finite set Sp ot of sp ots, a fixed but arbitra ry finite set Fie ld of fields, and a fixed but arbitrary finite set AtO bj of a to mic o b jects ha ve b een given. It is also assumed that a fixed but arbitra ry choic e function ch : ( P ( AtObj ) \ ∅ ) → AtObj suc h that, fo r all A ∈ P ( AtObj ) \ ∅ , ch ( A ) ∈ A has b een given. The function ch is used whenever a fresh atomic ob ject must be obtained. Below, we will informally explain the features o f DLD to structure data dynamically . When spea king informally abo ut a state L o f DLD, w e say: – if there exists a unique atomic ob ject a for which s − → a is contained in L , the c ontent of sp ot s instead of the unique a tomic ob ject a for which s − → a is contained in L ; – the fields of atomic obje ct a instead of the set of all fields f such that either a f − → is con tained in L or there ex ists an atomic ob ject b such that a f − → b is contained in L ; – if there exis ts a unique a tomic ob ject b for which a f − → b is contained in L , the c ontent of fi eld f of atomic obje ct a instead of the unique a tomic ob ject b for which a f − → b is contained in L . In the case where the uniqueness condition is met, the s po t or field concerned is called lo c al ly deterministic . DLD has the following basic actions to s tructure data dynamically: – for each s ∈ Sp ot , a get fr esh atomic obje ct action s !; – for each s, t ∈ Sp ot , a set sp ot action s = t ; – for each s ∈ Sp ot , a cle ar sp ot action s = ∗ ; – for each s, t ∈ Sp ot , an e quality test action s == t ; – for each s ∈ Sp ot , an undefine dness test action s == ∗ ; – for each s ∈ Sp ot and f ∈ Fiel d , a add field action s/f ; – for each s ∈ Sp ot and f ∈ Fiel d , a r emove field action s \ f ; – for each s ∈ Sp ot and f ∈ Fiel d , a has field action s | f ; – for each s, t ∈ Sp ot and f ∈ Field , a set field action s.f = t ; – for each s ∈ Sp ot and f ∈ Fiel d , a cle ar field action s.f = ∗ ; – for each s, t ∈ Sp ot and f ∈ Field , a get field action s = t.f . If only lo cally deterministic sp ots and fields are inv olved, these actions can be ex plained as follo ws: – s !: if a fresh a tomic ob ject can b e allo cated, then the conten t of spo t s bec omes that fresh atomic ob ject and the reply is T ; o therwise, nothing changes and the reply is F ; – s = t : the conten t o f sp ot s be comes the sa me as the co nt ent o f sp ot t and the reply is T ; – s = ∗ : the conten t of spo t s b eco mes undefined and the reply is T ; – s == t : if the conten t of sp ot s equals the conten t of sp o t t , then no thing changes and the reply is T ; otherwise, nothing c hanges and the reply is F ; – s == ∗ : if the conten t of sp o t s is undefined, then nothing changes and the reply is T ; otherwise, nothing c hanges and the reply is F ; 6 – s/f : if the conten t o f sp ot s is an ato mic ob ject a nd f do es not yet belong to the fields o f that ato mic ob ject, then f is added (with undefined conten t) to the fields of that atomic ob ject and the reply is T ; other wise, nothing changes and the reply is F ; – s \ f : if the conten t of sp ot s is an ato mic ob ject a nd f b elongs to the fields of that atomic ob ject, then f is remov ed from the fields o f that atomic ob ject and the reply is T ; other wise, nothing ch ang es a nd the reply is F ; – s | f : if the conten t of sp ot s is an ato mic o b ject and f be longs to the fields of that atomic o b ject, then no thing changes a nd the reply is T ; o therwise, nothing changes and the reply is F ; – s.f = t : if the co n tent of sp ot s is an a tomic ob ject a nd f b elongs to the fields of that atomic ob ject, then the conten t of tha t field b ecomes the same as the conten t of sp ot t a nd the re ply is T ; otherwise , nothing changes and the reply is F ; – s.f = ∗ : if the conten t of sp ot s is an a tomic ob ject and f b elo ng s to the fields of that ato mic ob ject, then the co nten t of that field b ecomes undefined and the reply is T ; other wise, nothing ch ang es a nd the reply is F ; – s = t.f : if the co nten t of sp ot t is an a to mic ob ject and f b elongs to the fields of that a tomic ob ject, then the con tent o f sp ot s b ecomes the same as the conten t of that field and the reply is T ; otherwise, nothing changes and the reply is F . In the explanation given above, wherever w e s ay that the co n tent of a sp ot or field bec omes the s ame as the cont ent of another spot or field, this is mea nt to imply that the former conten t b ecomes undefined if the latter co nt ent is undefined. If not only lo cally deter ministic sp ots and fields ar e in volved in p erfor ming an action, there is no s ta te ch ang e and the reply is F . A tomic ob jects that are no t reachable via spo ts and fields can be reclaimed. Reclamation of unreachable atomic ob jects is re le v a nt b ecause the set A tObj o f atomic ob jects is finite. In [9], we introduce v ario us ways to achieve r eclama- tion o f unreachable atomic o b jects. In this s ection, we mention only o ne of the reclamation- related actions: the ful l garb age c ol le ction action fgc . By p er forming this action, a ll unrea chable atomic ob jects are reclaimed. The r eply tha t results from perfo rming this action is alw ays T . W e write A DLD for the set o f all basic a ctions of DLD . In [9], we describ e the state changes and r eplies that result from per forming the basic actions of DLD by means o f a term rewr ite sys tem w ith rule prior i- ties [3]. F or that purp ose, a unary effe ct o p e rator eff α and a unar y yield op erator yld α are int ro duce d for each basic a ction α ∈ A DLD . The in tuition is that these op erator s sta nd for op era tions that give, for ea ch state L , the state and r eply , resp ectively , that result from per forming basic action α in state L . 4 Basic Thread Algebra In this section, we review the algebra ic theory BT A (Basic Thread Algebr a), a form of pr o cess a lgebra which is tailor ed to the description and analysis of the 7 T able 2. Axiom of BT A x E tau D y = x E tau D x T1 behaviours of se q uent ial prog rams under execution. The b ehaviours co ncerned are called thr e ads . In BT A, it is assumed that a fixed but arbitrary finite set A of b asic actions , with tau 6∈ A , ha s b een given. W e write A tau for A ∪ { tau } . The mem b ers of A tau are referred to as actions . Threads pro ceed by p erforming actions in a sequential fashion. Each bas ic action pe rformed by a thread is taken a s a command to b e pro c e ssed b y s ome service pr ovided b y the exe c utio n environmen t of the thread. The pr o cessing of a command may inv olve a c hange o f state of the ser vice co ncerned. A t completio n of the pro cessing of the command, the ser v ice r eturns a r e ply v alue T or F to the thread concerned. BT A ha s one s ort: the so rt T of thr e ads . T o build terms of sort T , BT A ha s the following consta nts and op er ators: – the de ad lo ck constant D : T ; – the termination co nstant S : T ; – for each α ∈ A tau , the bina ry p ostc onditional c omp osition op erator E α D : T × T → T . T erms of sort T a re built as usua l (see e.g. [29, 23]). Througho ut the paper , we assume that there are infinitely man y v ar iables of sort T , including x, y , z . W e use infix no tation for p ostco nditional co mp os ition. W e in tro duce action pr efixing a s an a bbreviation: α ◦ p , wher e p is a term of sort T , abbr eviates p E α D p . Let p and q b e clo sed terms of so rt T and α ∈ A tau . Then p E α D q will per form action α , a nd after that pro ceed as p if the pro cessing of α lea ds to the reply T (called a p ositive re ply ), and pr o ceed a s q if the pr o cessing of α leads to the reply F (called a negative reply ). The action tau plays a sp ecial ro le. It is a concrete internal a c tion: p erforming ta u will never lea d to a state change and alwa ys lea d to a p ositive r eply , but no t withstanding a ll that its pres ence matters. BT A ha s only one axiom. This ax iom is g iven in T able 2. Each clos ed BT A term of s o rt T denotes a finite thread, i.e. a thread o f which the length of the sequences of actions that it can p erfor m is bounded. Guar de d recursive sp ecificatio ns giv e rise to infinite thr eads. A guar de d r e cursive sp e cific ation ov er BT A is a set of recursion equations E = { X = p X | X ∈ V } , where V is a set of v ariables of sort T and ea ch p X is a term of the for m D , S or p E α D q with p and q BT A terms of sort T that contain only v aria bles from V . W e write V( E ) for the set of all v ariables tha t o ccur on the left-hand side of an equation in E . W e are only interested in mo dels of BT A in which gua r ded recurs ive sp ecifications hav e unique solutions, such as the pro jective limit mo del of BT A pr esented in [5]. 8 T able 3. Ax ioms for guarded recursion h X | E i = h t X | E i if X = t X ∈ E RDP E ⇒ X = h X | E i if X ∈ V( E ) RSP W e ex tend BT A with guarded r ecursion by adding co nstants for solutions of guarded recursive sp ecifica tions and axioms concerning these additional con- stants. F or ea ch guar de d recursive sp ecifica tion E and each X ∈ V( E ), we add a constant of sort T standing for the unique solution of E for X to the constants of BT A. The co nstant sta nding for the unique so lutio n of E for X is denoted b y h X | E i . Moreov er, we add the axioms for g uarded r ecursion given in T able 3 to BT A, where we write h t X | E i for t X with, for all Y ∈ V( E ), all o ccurr ences of Y in t X replaced by h Y | E i . 2 In this table, X , t X and E stand for an ar bitrary v a riable of sor t T , a n arbitrar y BT A term o f sort T and an arbitr ary g uarded recursive sp ecification ov er BT A, resp ectively . Side conditions are added to re - strict the v ariables, terms and guarded re c ursive sp ecifications for which X , t X and E stand. Henceforth, we write BT A+REC for BT A extended with the constants for so - lutions o f guar ded recursive s p ecifica tions and a x ioms RDP and RSP . Mor eov er, we write T for the set of all closed terms of BT A+REC. In the following definition, the interpretation of a p ostconditional comp os i- tion op er ator in a model of BT A+REC is denoted by the oper ator itself. Let M be so me mo del o f BT A+REC, and let p b e an element fr om the domain o f M . Then the set of r esidual thr e ads of p , wr itten R es ( p ), is inductively defined a s follows: – p ∈ R es ( p ); – if q E a D r ∈ R es ( p ), then q ∈ R es ( p ) and r ∈ Res ( p ). W e say that p is r e gular if R es ( p ) is finite. W e a re o nly interested in mo dels of B T A+RE C in which the solution of a guarded rec ur sive specification E over B T A is reg ula r if and only if E is finite, such as the pro jective limit mo del pre sented in [5]. Par abus de langa ge, a closed term of BT A+REC w itho ut o ccurr ences o f constants h X | E i for infinite E will henceforth be calle d a r e gular thr e ad . 5 A Use Mec hanism for F orecasting Services A thread may p er form an actio n for the purp ose of interacting with a s ervice that takes the action as a command to b e pro cessed. The pro cess ing of the action may inv olve a c hange o f state o f the s ervice and at completion o f the proces sing of the action the serv ice returns a reply v alue to the thread. In this sec tio n, w e int ro duce a mechanism that is concerned with this kind of interaction. It is a 2 Throughout th e p ap er, we use the symbol ⇒ for implication. 9 generaliza tion of the use mechanism intro duced in [9] to fore casting services. A forecasting ser vice is a ser vice of which the state changes and replies may dep end on ho w the thread that perfor ms the actions being pro c e ssed will pr o ceed. It is assumed tha t a fixed but a rbitrary finite set F of fo ci and a fixed but arbitrar y finite set M of metho ds have b een g iven. E ach fo cus plays the role of a name of so me ser vice provided by a n execution environmen t that can b e requested to pro cess a co mmand. Each metho d pla ys the r ole of a comma nd prop er. F or the set A of actions, we take the s et { f .m | f ∈ F , m ∈ M} . Performing an action f .m is ta ken as ma king a r equest to the se rvice named f to pro cess command m . Recall that T stands for the set of a ll closed ter ms of BT A+REC. A for e c asting servic e H co ns ists of – a set S of states ; – an effe ct function eff : M × S × T → S ; – a yield function yld : M × S × T → { T , F , B } ; – an initial state s 0 ∈ S ; satisfying the following conditions: ∃ s ∈ S • ∀ m ∈ M , p ∈ T • ( yld ( m, s, p ) = B ∧ ∀ s ′ ∈ S • ( yld ( m, s ′ , p ) = B ⇒ eff ( m, s ′ , p ) = s )) , ∀ s ∈ S, m, m ′ ∈ M , f ∈ F , p, q ∈ T • ( yld ( m, s, S ) = B ∧ yld ( m, s, D ) = B ∧ yld ( m, s, tau ◦ p ) = B ∧ ( m 6 = m ′ ⇒ yld ( m, s, p E f .m ′ D q ) = B )) . The set S contains the s tates in which the s ervices may b e, a nd the functions eff a nd yld give, fo r each metho d m , state s and thread p , the state and reply , resp ectively , that result from pr o cessing m in state s if p is the thread that ma kes the request to proces s m . In cer ta in states, r equests to proce s s cer tain methods may b e rejected. B , which stands for blo cked, is used to indicate this. Given a foreca sting s ervice H = ( S, eff , yld , s 0 ), a metho d m ∈ M a nd a thread p ∈ T : – the derive d s ervic e of H after pro cessing m in the context of p , written ∂ ∂ m H [ p ], is the foreca sting se r vice ( S, eff , yld , eff ( m, s 0 , p )); – the re ply of H after pro cessing m in the co nt ext of p , wr itten H [ p ]( m ), is yld ( m, s 0 , p ). A forecasting service H = ( S, eff , yld , s 0 ) can be understo o d as follows: – if thread p makes a re quest to the service to pr o cess m and H [ p ]( m ) 6 = B , then the request is a ccepted, the reply is H [ p ]( m ), a nd the service pro ceeds as ∂ ∂ m H [ p ]; – if thread p makes a re quest to the service to pr o cess m and H [ p ]( m ) = B , then the request is rejected. 10 T able 4. Ax ioms for u se op erators S / f H = S TSU1 D / f H = D TSU2 ( tau ◦ p ) / f H = tau ◦ ( p / f H ) TSU3 ( p E g .m D q ) / f H = ( p / f H ) E g .m D ( q / f H ) if f 6 = g TSU4 ( p E f .m D q ) / f H = tau ◦ ( p / f ∂ ∂ m H [ p E f .m D q ]) if H [ p E f .m D q ]( m ) = T TSU5 ( p E f .m D q ) / f H = tau ◦ ( q / f ∂ ∂ m H [ p E f .m D q ]) if H [ p E f .m D q ]( m ) = F TSU6 ( p E f .m D q ) / f H = D if H [ p E f .m D q ]( m ) = B TSU 7 By the firs t co ndition o n for ecasting services, after a req uest ha s b een re jected by the serv ice, it gets in to a state in whic h any r e quest will be r ejected. By the second condition on fo r ecasting services, any r e q uest that do es no t corres po nd to the action being p erformed by thr ead p is r ejected. In the case o f a forecasting ser v ice H = ( S, eff , yld , s 0 ), the derived s ervice and reply that result fro m proces sing a metho d may dep end on how the thread that makes the request to pro ces s that metho d will pro ceed. Hence the name forecasting service. Henceforth, we will omit the qualificatio n forec asting if no confusion can arise with other kinds of ser vices. W e in tro duce yet another sort: the sor t S of servic es . How ever, we will not int ro duce constants and ope r ators to build terms of this sor t. W e demand that the interpretation of the sor t S in a mo del is a set F S o f foreca sting se rvices such that for all H ∈ F S , ∂ ∂ m H [ p ] ∈ F S for each m ∈ M and p ∈ T . W e in tro duce the following additional op erator s: – for each f ∈ F , the binary use op er ator / f : T × S → T . W e use infix no tation for the us e op erators . Int uitively , p / f H is the thread that results from pro cessing all actions per - formed b y thr e ad p that are of the form f .m b y servic e H . When an action of the form f .m p erformed by thread p is pro ces sed by ser vice H , that action is turned into the in terna l action tau and po stconditional comp ositio n is removed in fav our of action prefixing on the basis of the reply v alue pro duced. In previo us work, w e sometimes opted for the alter na tive to conceal the pro cessed actio ns completely . How ever, w e exp e rienced rep eatedly in ca ses where this alternative app eared to be appro priate at first tha t it turned out to imp ede progr e ss later. The axio ms for the use o pe r ators ar e giv en in T able 4. In this table, f and g stand for arbitr ary fo ci fr om F , m stands for a n arbitrary metho d from M , and p and q stand for arbitr ary closed terms of so rt T . H ranges over the interpretation of so rt S . Axio ms TSU3 and TSU4 expres s that the action tau and actions of the form g .m , where f 6 = g , are not pro c essed. Axioms TSU5 and TSU6 express that a thread is affected by a servic e as describ ed a b ove when an action o f the form f .m is pro c essed by the s ervice. Axiom TSU7 ex presses tha t deadlo ck takes place when an a ction to be pro cessed is not accepted. Henceforth, we write B T A use for B T A, tak ing the s e t { f .m | f ∈ F , m ∈ M} for A , extended with the us e o p erators and the axioms fro m T a ble 4. 11 T able 5. Defin ition of effect and yield functions for D LD eff ( m, L, p E f .m D q ) = eff m ( L ) if m ∈ A DLD eff ( m, L, p E f .m D q ) = ↑ if m 6∈ A DLD yld ( m, L, p E f .m D q ) = yld m ( L ) if m ∈ A DLD yld ( m, L, p E f .m D q ) = B if m 6∈ A DLD yld ( m, L, p ) = B ⇒ eff ( m, L, p ) = ↑ The use mechanism introduced in [8] deals in e s sence with forec asting ser v ices of which: – the set of s tates is the set of all sequences with elements from M ; – the derived service a nd reply that r esult fro m pro cessing a metho d do no t depe nd on how the threa d that ma kes the req ues t to pr o cess that metho d will pro ceed. F or these services, the use mechanism introduced in this section coincides with the use mechanism in tro duced in [8]. The ar chitecture-dependent servic es con- sidered in [6] can b e lo oked upon as simple foreca sting s ervices. 6 Thread Algebra and Data Link age Dynamics Com bined The state changes a nd replies that r e sult from p erforming the actions of data link a ge dynamics ca n b e achieved by means of services. In this sho rt section, we explain how basic thread alg ebra can be combined with da ta link age dyna mics by means of the use mec hanism in tro duced in Section 5 such that the whole can b e us ed for studying issues concerning the use of dynamic data struc tur es in progra mming. The service s inv olved do no t have a for ecasting nature. The adapted serv ices needed to deal with shedding , which a re describ ed in Section 9, hav e a for ecasting nature. Recall tha t DL stands for the set of a ll elements of the initial mo de l of DLA, and recall that, for each α ∈ A DLD , eff α and yld α stand for unar y o per ations on D L that give, for L ∈ D L , the state and r eply , resp ectively , that r esult from per forming basic action α in s tate L . It is assumed that a blo cking s tate ↑ 6∈ D L has been given. T ake M such that A DLD ⊆ M . Mo reov er, let L ∈ D L ∪ {↑} . Then the data linkage dynamics servic e with initial state L , written D L D ( L ), is the service ( D L ∪ {↑} , eff , yld , L ), where the functions eff and yld a re the effect a nd yie ld functions satisfying the (unconditional and conditional) equa tions in T able 5 . Notice that, b ecause of the conditions imp os e d on forecas ting services in Sec- tion 5, these equations character ize the effect and yield functions uniquely . By means of threads and the data link a ge dynamics ser vices intro duced ab ov e, we can give a precise pictur e of computatio ns in which dynamic data structures are in volv ed. Examples of suc h computations can be found in [9]. 12 The combin atio n of basic thread algebr a and data link a g e dynamics by means of the use mech anism can be used for studying iss ues concerning the use of dynamic data structures in pro gramming a t the level of pro gram b ehaviours. A hierarch y of simple prog r am notations ro oted in P GA is presented in [7]. Included are pro gram no tations which are clo s e to existing assembly language s up to a nd including pr o gram no tations that supp or t structure d pro gramming by offering a r endering of conditional and lo o p cons tructs. Reg ular threads are taken as the behaviours of progr ams in those prog r am no tations. T ogether with one of the progra m notatio ns, the combination of basic threa d alge br a and data link age dynamics can b e used for studying issues c o ncerning the use of dynamic data structures in pr o gramming at the level of pr ogra ms . W e men tion one such issue. In g eneral terms, the issue is whe ther we can do without g arbage collection by progr am tra nsformation at the price of a linear increase of the num ber of av ailable atomic ob jects. In [9], we phrase this issue precisely fo r one of the progra m notatio n roo ted in PGA. The nota tio n for the basic actions o f DLD, ma kes the fo cus-metho d notation f .m less suitable in the case where m is a basic a ction o f DLD. Ther efore, we will henceforth mostly write f ( m ) instead of f .m if m ∈ A DLD . 7 The Shedding F eature In this section, we in tro duce the shedding feature in the setting of data link age dynamics in an informal wa y . In Section 9, we will adapt the data link age dy- namics serv ic es introduced in Section 6 to explain s hedding in a mor e precise wa y . Roughly sp eaking, s he dding works as follows: each time the conten t of a sp ot or field is changed, it is de ter mined whether or not the sp o t or field will p os sibly be used once again, and if not its conten t is made undefined. If a s po t or field is made undefined in this wa y , we s ay that it is shed. The use of a previously she d sp ot or field is called a shedding er ror. The shedding feature is ra ther non-obvious. Consider the thread dld ( s !) ◦ (( dld ( u = s ) ◦ S ) E dld ( t !) D S ) and as sume that the car dinality of A tObj is 1. If s is not shed on perfor ming s !, then a negative reply is pro duced o n p erfor ming t ! a nd the threa d terminates without having made use of s . How ever, from this it ca nnot b e concluded that s could be shed on p erfor ming s ! after all. If s w ould b e shed on p erforming s !, a p ositive reply would be pro duced o n p erforming t ! and after that a shedding error w ould o ccur. This shows that shedding b ecomes paradoxical if we do not deal pr op erly with the fact that shedding of a sp ot or field influences whether or not that spot or field will po ssibly be used onc e aga in. In the ligh t o f this, it is of the utmost importa nce to hav e the right criter io n for shedding in mind: a sp o t o r field can safely b e shed if it is not p ossible for the progr am behaviour under co nsideration to evolv e in the case wher e that sp ot 13 or fie ld is shed, ir resp ective as to whether o ther sp ots and fields a re subsequently shed, in such a wa y that the first shedding e r ror concer ns that spo t or field. When sp eaking a bo ut applications o f this cr iterion, shedding err ors that co nce rn the sp ot or field to which the criterio n is a pplied are called primary shedding error s and other shedding error s are called se c ondary shedding err o rs. In Sec tion 6, it was explained how ba sic threa d a lgebra ca n be combined with data link age dyna mics by means of the use mechanism from Section 5 in such a way tha t the who le can be used for s tudying issues concerning the use of dynamic data structures in progr a mming. F or a clea r appr ehension of data link age dynamics as presented in Section 3, such a co mbination is not needed. This is different for shedding: it cannot b e explained without reference to progra m be haviours. In Section 9, we a dapt the da ta link age dynamics s ervices inv olved in the combination describe d in Sectio n 6 to expla in shedding. F or the a dapted data link age dynamics ser vices, shedding happ ens to b e a matter close to reflection on itself. Material to the adaptation is the ab ov e- men tioned cr iterion for shedding a s po t or field. Instrumental in chec king this criterion a re the data link a ge dynamics ser vices for a mino r v ariation o f DLD . It concerns services whic h supp ort the mimicking of shedding. 8 Mimic king of Sheddin g The shedding supp orting da ta link age dynamics serv ices, which w ill be in tro- duced in Se c tio n 9, c heck the criterio n for shedding adopted in Sec tion 7 by determining wha t w ould ha ppen if mimicking of shedding supporting data link- age dynamics service s were used. In this section, we describ e the mimicking of shedding suppor ting data link a g e dynamics services in ques tion. These ser vices ar e data link age dyna mics ser vices for a v ariation of DLD. The v a riation concerned, referred to as DLD msh , differs from DLD as follows: – it has t wo additional atomic ob jects ∗ p and ∗ s ; – for each s ∈ Sp ot , it has t wo additional ba sic actions s = ∗ p and s = ∗ s ; – for each s ∈ Sp ot and f ∈ Field , it has tw o additional basic a ctions s.f = ∗ p and s.f = ∗ s ; – on perfor ming s !, the co nt ents of sp ot s never b ecomes ∗ p or ∗ s ; – on perfor ming fgc , ∗ p and ∗ s are nev er reclaimed. If only lo cally deterministic sp ots and fie lds ar e inv olved, the additiona l bas ic actions can be expla ined as follows: – s = ∗ p : the cont ent of sp ot s b ecomes ∗ p and the reply is T ; – s = ∗ s : the co nten t of sp ot s b ecomes ∗ s and the reply is T ; – s.f = ∗ p : if the conten t of s po t s is an atomic o b ject and f b elo ng s to the fields o f tha t atomic ob ject, then the co n tent o f that field b ecomes ∗ p and the reply is T ; otherwise, nothing changes and the reply is F ; 14 T able 6. Defin ition of effect and yield functions for DLD with mimic king of shedd ing eff msh ( m, L, p E f .m D q ) = eff msh m ( L ) if m ∈ A DLD msh eff msh ( m, L, p E f .m D q ) = ↑ if m 6∈ A DLD msh yld msh ( m, L, p E f .m D q ) = yld msh m ( L ) if m ∈ A DLD msh yld msh ( m, L, p E f .m D q ) = B if m 6∈ A DLD msh yld msh ( m, L, p ) = B ⇒ eff msh ( m, L, p ) = ↑ – s.f = ∗ s : if the conten t of sp o t s is an a to mic ob ject and f b elongs to the fields of tha t a tomic ob ject, then the conten t of that field b ecomes ∗ s and the reply is T ; otherwise, nothing changes and the reply is F . If not only lo cally deter ministic sp ots and fields ar e in volved in p erfor ming an action, there is no s ta te ch ang e and the reply is F . The special a tomic ob jects ∗ p and ∗ s are used as follo ws: – when chec king of the criterio n for some spot or field starts, the shedding o f that spo t or field is mimic ked by s e tting its co nten t to ∗ p ; – during chec king, the shedding o f another sp ot or field is mimic ked by setting its conten t to ∗ s . If a sp o t o r field is used whose conten t is ∗ p , a mimick ed pr imary shedding error is encountered and, if a sp ot or field is used whose conten t is ∗ s , a mimick ed secondary shedding error is encoun tered. Different s ets of sp ots, s ets of fields or sets of atomic ob jects give r is e to different instances of DLA. The states of DLD a re the ele men ts of the initial mo del o f so me instance of DLA . Beca use of the tw o a dditio na l a tomic ob jects, the states of DLD msh are the elements of the initial mo de l of another instance of DLA. Henceforth, we wr ite D L for the set of all elements of the initial mo del of for mer insta nce of DLA and D L msh for the set of all elements of the initial mo del of latter ins tance of DLA. In [9], we describ e the state changes a nd replies that res ult from p er fo rming basic actions of DLD by mea ns of a term rewrite system with rule priorities . It is obvious ho w that term rewrite system must b e adapted to obtain a term rewr ite sys tem descr ibing the s tate changes and replies that res ult fr om p erforming ba sic actions of DLD msh . F or each ba sic action α of DLD msh , we write eff msh α and yld msh α for the effect and yield ope rators tha t go with α in the latter term r ewrite system. Moreover, we write A DLD msh for the set of all basic actions of DLD msh . Let L ∈ D L msh ∪ {↑ } . Then the mimicking of she dding supp orting data linkage dynamics servic e w ith initial state L , written DL D msh ( L ), is the service ( D L msh ∪ {↑} , eff msh , yld msh , L ), where the functions eff msh and yld msh are the effect and yield functions satisfying the equations in T able 6. 15 9 Shedding Support ing Data Link age Dynamics Services In this section, we turn to the data link age dynamic services tha t suppo rt shed- ding themselves. W e a ssume that dld ∈ F . It is supp osed tha t r equests to a shedding suppor t- ing data link age dynamics ser vice to pro cess ba sic a c tions o f DLD are a lwa ys made using the fo cus dld . W e write A sh DLD for the s et of all basic actions of DLD that are of the fo r m s !, s = t , s.f = t or s = t.f . In the definition o f shedding supp orting data link age dyna mics services g iven below, we use an auxilia r y function sh : A DLD → A DLD and a set shok ⊆ T × D L . The function sh gives, fo r each bas ic ac tio n of DLD for changing the co nten t of a s p o t or field, the bas ic ac tio n of DLD for making the conten t of that sp ot or field undefined. F or each other basic action of DLD, s h g ives the basic action itself. The function sh is defined as follows: sh ( s !) = ( s = ∗ ) , sh ( s = t ) = ( s = ∗ ) , sh ( s.f = t ) = ( s.f = ∗ ) , sh ( s = t.f ) = ( s = ∗ ) , sh ( α ) = α if α 6∈ A sh DLD . In the definition o f the set shok , we use an auxilia ry function msh : { 0 , 1 , 2 } × A DLD → A DLD msh and, fo r ea ch L ∈ D L msh , sets n osher r ( L ) , se cmsherr ( L ) ⊆ A DLD . The function msh gives, for each natura l num ber in the s et { 0 , 1 , 2 } and each basic a ction o f DLD for ch ang ing the con tent of a s p o t or field: the basic action itself if the num be r is 0, the basic action of DLD msh for making the conten t of that s po t o r field ∗ p if the num b er is 1, and the basic action of DLD msh for making the conten t of that sp ot or field ∗ s if the num b er is 2. F or each other basic a ction of DLD, msh g ives always the basic action itself. The function msh is defined as fo llows: msh (0 , α ) = α , msh (1 , s !) = ( s = ∗ p ) , msh (1 , s = t ) = ( s = ∗ p ) , msh (1 , s.f = t ) = ( s.f = ∗ p ) , msh (1 , s = t.f ) = ( s = ∗ p ) , msh ( i, α ) = α if α 6∈ A sh DLD , msh (2 , s !) = ( s = ∗ s ) , msh (2 , s = t ) = ( s = ∗ s ) , msh (2 , s.f = t ) = ( s.f = ∗ s ) , msh (2 , s = t.f ) = ( s = ∗ s ) . F or each L ∈ D L msh , the set nomsherr ( L ) contains all basic actio ns α ∈ A DLD whose use in state L do es not amo unt to a mimick ed shedding err or and the set se cmsherr ( L ) contains all basic actions α ∈ A DLD whose us e in state L amounts to a mimick ed seco ndary shedding erro r. F or each L ∈ D L msh , the set nomsherr ( L ) is inductiv ely defined as follows: – s ! , s = ∗ ∈ nomsherr ( L ); – if L ⊕ ( s − → a ) = L , a 6 = ∗ p and a 6 = ∗ s , then t = s, s == ∗ , s/f , s \ f , s | f ∈ nomsherr ( L ); 16 – if L ⊕ ( s − → a ) ⊕ ( t − → b ) = L , a 6 = ∗ p , a 6 = ∗ s , b 6 = ∗ p and b 6 = ∗ s , then s == t, s.f = t ∈ nomsherr ( L ); – if L ⊕ ( s − → a ) ⊕ ( a f − → b ) = L , a 6 = ∗ p , a 6 = ∗ s , b 6 = ∗ p and b 6 = ∗ s , then t = s.f ∈ nomsherr ( L ); and the set se cmsherr ( L ) is inductiv ely defined as follo ws: – if L ⊕ ( s − → ∗ s ) = L , then t = s, s == t, t == s, s == ∗ , s/f , s \ f , s | f , s.f = t, t.f = s, t = s .f ∈ se cmsherr ( L ); – if L ⊕ ( s − → a ) ⊕ ( a f − → ∗ s ) = L , then t = s.f ∈ se cmsherr ( L ). The set shok contains all pa irs ( p, L ) ∈ T × D L such that, if the first action that is p erformed b y p is an action of the form dld .m , where m is a basic action of DLD for c hanging the con tent of a sp ot or field, the criterion for shedding of that sp ot or field is met. The g eneral idea underly ing the definitio n of shok given below is that the criter ion for shedding can be chec ked by mimicking shedding. In ch ecking, all p os sibilities m ust b e considered: – if an actio n of the for m f .m with f 6 = dld is encountered, then tw o poss ibilities arise: (i) the reply is T a nd (ii) the re ply is F ; – if an action of the for m dld .m with m a basic action o f DLD of the form s !, s = t , s.f = t or s = t.f is encountered, then tw o p os s ibilities ar ise: (i) the sp ot or field eligible for s hedding is not shed and (ii) the s po t or field eligible for shedding is shed. In general, this means that many paths m ust b e follow ed. F or regular threads, the num ber of paths to b e followed will r emain finite and even tually either ter- mination, deadlo ck, a mimick ed pr imary shedding er ror, a mimicked secondary shedding er ror o r a cycle without mimic ked shedding errors will be encountered along ea ch o f the pa ths to b e fo llowed. T he criter ion fo r she dding is met if a long each o f the pa ths to b e follow ed it is not a mimicked prima ry s hedding erro r that is encountered firs t. F o r no n-regular threads, it is undecidable whe ther the criterion for shedding is met. The set s hok is defined by shok = shok ′ (1 , ∅ ), where the sets shok ′ ( i, C ) ⊆ T × D L msh for i ∈ { 0 , 1 , 2 } and C ⊆ T × D L msh are defined by simult aneo us induction as follows: – ( S , L ) , ( D , L ) ∈ shok ′ ( i, C ); – if f 6 = dl d , ( p, L ) ∈ shok ′ (0 , C ∪ { ( p E f .m D q , L ) } ), ( p, L ) ∈ shok ′ (2 , C ∪ { ( p E f .m D q , L ) } ), ( q , L ) ∈ shok ′ (0 , C ∪ { ( p E f .m D q , L ) } ), ( q , L ) ∈ shok ′ (2 , C ∪ { ( p E f .m D q , L ) } ), then ( p E f .m D q , L ) ∈ shok ′ ( i, C ); 17 T able 7. Defin ition of effect and yield functions for DLD with shed ding eff sh ( m, L, p E f .m D q ) = eff sh ( m ) ( L ) if m ∈ A DLD ∧ ( p E f .m D q , L ) ∈ shok eff sh ( m, L, p E f .m D q ) = eff m ( L ) if m ∈ A DLD ∧ ( p E f .m D q , L ) 6∈ shok eff sh ( m, L, p E f .m D q ) = ↑ if m 6∈ A DLD yld sh ( m, L, p E f .m D q ) = yld sh ( m ) ( L ) if m ∈ A DLD ∧ ( p E f .m D q , L ) ∈ shok yld sh ( m, L, p E f .m D q ) = yld m ( L ) if m ∈ A DLD ∧ ( p E f .m D q , L ) 6∈ shok yld sh ( m, L, p E f .m D q ) = B if m 6∈ A DLD yld sh ( m, L, p ) = B ⇒ eff sh ( m, L, p ) = ↑ – if m ∈ nomsherr ( L ), ( p E dld . msh ( i, m ) D q ) / dld D L D msh ( L ) = tau ◦ ( r / dld D L D msh ( L ′ )), ( r , L ′ ) ∈ shok ′ (0 , C ∪ { ( p E dld .m D q , L ) } ), ( r , L ′ ) ∈ shok ′ (2 , C ∪ { ( p E dld .m D q , L ) } ), then ( p E dld .m D q , L ) ∈ shok ′ ( i, C ); – if m ∈ se cmsherr ( L ), then ( p E dld .m D q , L ) ∈ shok ′ ( i, C ); – if h X | E i ∈ T , X = t X ∈ E , ( h t X | E i , L ) ∈ shok ′ ( i, C ), then ( h X | E i , L ) ∈ shok ′ ( i, C ); – if ( p, L ) ∈ C , then ( p, L ) ∈ shok ′ ( i, C ). In shok ′ ( i, C ), i co rresp onds to the wa y in which a basic action of DLD for changing the conten t of a sp ot o r field is dealt with in c hecking: – without mimic king of its shedding if i = 0; – with mimic king of its shedding b y means of ∗ p if i = 1; – with mimic king of its shedding b y means of ∗ s if i = 2. The mem b ers of C co rresp ond to the combinations of threa d and state encoun- tered befo r e in chec king. If such a combination is enco unt ere d ag ain, this indi- cates a cycle without shedding error s b ecause a path is no t follow ed further a fter termination, dea dlo ck, a mimick ed shedding err or or a cy c le without mimick ed shedding errors has been encountered. By the o ccurrence of the equation ( p E dld . msh ( i, m ) D q ) / dld D L D msh ( L ) = tau ◦ ( r / dld D L D msh ( L ′ )) in the third rule of the inductive definition of the sets shok ′ ( i, C ), a service that is engage d in chec king whether a pa ir ( p, L ) ∈ T × D L belo ngs to shok is clos e to refle c ting on itself. Now, we are r eady to de fine, for L ∈ D L ∪ {↑} , a data link a ge dynamic serv ice D L D sh ( L ) that suppo rts shedding. Let L ∈ D L∪{ ↑} . Then the she dding supp orting data linkage dynamics servic e with initial s tate L , written D L D sh ( L ), is the service ( D L ∪ {↑} , eff sh , yld sh , L ), where the functions eff sh and yld sh are the effect and yield functions satisfying the equations in T able 7 . 18 10 Examples In this section, we give tw o examples that illustrate how the definition of shed- ding supp or ting data link ag e dyna mics services can b e used to determine whether in a fixed ca se a sp o t o r field, whose conten ts s hould b e changed, is shed. The first example concerns a case where a spot is shed and the second example concerns a case where a sp ot is not shed. Example 1. Let p = dld ( s !) ◦ ( S E dld ( t !) D D ) , p ′ = S E dld ( t !) D D , p ′′ = S E dld ( t = ∗ s ) D D . Thread p ′ is a res idual thread of p a nd threa d p ′′ is p ′ with t ! replaced b y t = ∗ s to mimic shedding. Assume that the cardinality of AtO bj is 1 , and let a b e the unique ato mic ob ject such that A tObj = { a } . Then in p / dld D L D sh ( ∅ ), sp ot s is shed o n p erforming s !. This is str aightforw ardly shown using the definition of shedding supp o rting data link a ge dynamics s ervices. It follows immediately from the definition of nomsherr that: ( s !) ∈ nomsherr ( ∅ ) , ( t !) ∈ nomsherr ( s − → ∗ p ) , and it follo ws easily from the axioms for the use o per ators and the definition of mimic king of shedding supp orting data link ag e dynamics services that: p / dld D L D sh ( ∅ ) = tau ◦ ( p ′ / dld D L D sh ( s − → ∗ p )) , p ′ / dld D L D sh ( s − → ∗ p ) = tau ◦ ( S / dld D L D sh (( s − → ∗ p ) ⊕ ( t − → a ))) , p ′′ / dld D L D sh ( s − → ∗ p ) = tau ◦ ( S / dld D L D sh (( s − → ∗ p ) ⊕ ( t − → ∗ s ))) . Hence, b y the definitions of shok ′ and shok : ( p ′ , s − → ∗ p ) ∈ shok ′ (0 , { ( p, ∅ ) } ) , ( p ′ , s − → ∗ p ) ∈ shok ′ (2 , { ( p, ∅ ) } ) , ( p, ∅ ) ∈ shok ′ (1 , ∅ ) , ( p, ∅ ) ∈ shok . F rom this it fo llows by the definition of eff sh that eff sh ( s ! , ∅ , p ) = eff sh( s !) ( ∅ ). On account of shedding, we hav e that p / dld D L D sh ( ∅ ) = tau ◦ tau ◦ S , whereas p / dld D L D ( ∅ ) = tau ◦ tau ◦ D . The po int is that a pos itive reply is produced o n performing t ! only if spo t s is shed on perfo r ming s !. 19 Example 2. Let p = dld ( s !) ◦ (( dld ( u = s ) ◦ S ) E dld ( t !) D S ) , p ′ = ( dl d ( u = s ) ◦ S ) E dld ( t !) D S , p ′′ = d ld ( u = s ) ◦ S . Thread p is the same thread as the one discussed in Section 7 and threads p ′ and p ′′ are residual threa ds of p . Assume ag a in that the car dinality o f AtObj is 1, and let a be the unique atomic ob ject such that AtObj = { a } . Then in p / dld D L D sh ( ∅ ), sp o t s is not shed o n p erforming s !. This is easily shown using the definition of shedding supp o rting data link a ge dynamics services. It fo llows immediately fro m the definition o f nomsherr , the definition of se cmsherr , and basic set theory that: ( u = s ) 6∈ nomsherr (( s − → ∗ p ) ⊕ ( t − → a )) , ( u = s ) 6∈ se cmsherr (( s − → ∗ p ) ⊕ ( t − → a )) , ( p ′′ , ( s − → ∗ p ) ⊕ ( t − → a )) 6∈ { ( p, ∅ ) , ( p ′ , s − → ∗ p ) } , and it follo ws easily from the axioms for the use o per ators and the definition of mimic king of shedding supp orting data link ag e dynamics services that: p / dld D L D sh ( ∅ ) = tau ◦ ( p ′ / dld D L D sh ( s − → ∗ p )) , p ′ / dld D L D sh ( s − → ∗ p ) = tau ◦ ( S / dld D L D sh (( s − → ∗ p ) ⊕ ( t − → a ))) . Hence, b y the definitions of shok ′ and shok : ( p ′′ , ( s − → ∗ p ) ⊕ ( t − → a )) 6∈ shok ′ (0 , { ( p, ∅ ) , ( p ′ , s − → ∗ p ) } ) , ( p ′ , s − → ∗ p ) 6∈ shok ′ (0 , { ( p, ∅ ) } ) , ( p, ∅ ) 6∈ shok ′ (1 , ∅ ) , ( p, ∅ ) 6∈ shok . F rom this it fo llows by the definition of eff sh that eff sh ( s ! , ∅ , p ) = eff s ! ( ∅ ). 11 Conclusions W e have introduced s hedding in the setting of data link a ge dynamics and hav e adapted the data link a ge dynamics services describ ed in [9] s o that they supp or t shedding. T he ada ptation shows that the s hedding fea tur e is ra ther non-obvious. In particular , it is striking how m uch the matter is complicated by taking into consideratio n the semantic effects of the fact that the num ber of data ob jects that can exist at the sa me time is alw ays bo unded. W e co nsider the w ork presented in this pape r a s emantic v alidation of shed- ding. It is an en tirely different ques tion whether a real implemen tation of shed- ding is of any use in pr actice. W e have not answered this questio n. Empirical studies, see e.g. [17], indicate that in gener al a lar ge par t o f the da ta ob jects that are reachable at a pro gram point are actually not used beyond that po int. How ever, the static approximation of s hedding pro po sed in [1 8] might b e more useful in practice. 20 In the definition of shedding s uppo rting data link age dynamics ser vices, be- longing to shok corr esp onds to meeting the criterio n for shedding. The set shok is defined using the idea of mimicked s hedding. As a r esult, the description of the cr iterion for shedding lo o ks to be rather concrete. It is an open question whether a more abstra ct description of the criterion for shedding can be given. If so, o ur c o ncrete descr iption sho uld b e cor r ect with resp ect to tha t abstra ct description. In the case of shedding, the use of for ecasting turns out to b e semantically feasible. No restr ictions are needed to pr eclude forec a sting from introducing something paradoxical. This is cer tainly not a lwa ys the case . F or example, in the case of the halting problem, the use o f forecasting is not s emantically feasible, see e.g. [1 0], and in the case o f secur it y ha zard r is k asses sment, the use of for ecasting requires certain restrictions, see e.g. [6]. References 1. Agesen, O., Detlefs, D ., Moss, J.E.: Garbage collection and local v ariable typ e- precision and liveness in jav a virtual machines. ACM SIGPLAN Notices 33 (5), 269–279 (1998) 2. App el, A.W.: R untime tags aren’t necessary . Lisp and Symbolic Computation 2 (2), 153–162 (1989) 3. Baeten, J.C.M., Bergstra, J.A., Klop, J.W., W eijland, W .P .: T erm-rewriting sys- tems with rule priorities. Theoretical Computer Science 67 (2–3), 283– 301 (1989) 4. Bak er Jr., H.G.: List processing in real time on a serial comp u ter. Comm unications of the ACM 21 (4), 280–294 (1978) 5. Bergstra, J.A., Bethke, I.: Po larized pro cess algebra an d p rogram equiv alence. In: J.C.M. Baeten, J.K. Lenstra, J. P arrow, G.J. W o eginger (eds.) Proceedings 30th ICALP , L e ctur e Notes in Computer Scienc e , vol. 2719, pp. 1–21. Springer-V erlag (2003) 6. Bergstra, J.A., Beth ke, I., Po nse, A.: Thread algebra and risk assessmen t services. In: C. Dimitracopoulos, L. New elski, D. Normann (eds.) Logic Colloquium 2005, pp. 1–17. Sp rin ger-V erlag (2007) 7. Bergstra, J.A., Lo ots, M.E.: Program algebra for sequential cod e. Journal of Logic and Algebraic Progra mming 51 (2), 125– 156 (2002) 8. Bergstra, J.A., Middelburg, C.A.: Thread algebra for strategic in terleaving. F ormal Asp ects of Computing 19 (4), 445–474 (2007) 9. Bergstra, J.A., Middelburg, C.A.: Data link age algebra, d ata link age dy nam- ics, and priorit y rewriting. Electronic Rep ort PRG0 806, Programming Research Group, U niversit y of Amsterdam (2008). A vail able from http://arxiv.org / : arXiv:0804 .4565v2 [cs.LO] 10. Bergstra, J.A., Ponse, A.: Execu t ion arc hitectures for program algebra. Journal of Applied Logic 5 (1), 170–192 (2007) 11. Bo ehm, H .J., W eiser, M.: Garbage collection in an unco op erative environmen t. Soft ware Practice and Exp erience 18 (9), 807–820 (1988) 12. Collins, G.E.: A meth o d for ove rlapping and erasure of lists. Comm unications of the ACM 3 (12), 655–65 7 (1960) 13. D ijkstra, E.W., Lamp ort, L., Martin, A.J., Scholten, C.S., Steffens, E.F.M.: On- the-fly garbage collection: An exercise in co op eration. Comm unications of the ACM 21 (11), 966–975 (1978) 21 14. F enic hel, R.R., Y ochelson, J.C.: A LISP garbage-collector for v irtual-memory com- puter systems. Communications of the ACM 12 (11), 611 –612 (1969) 15. Gelernter, H., Hansen, J.R., Gerb erich, C.L.: A fortran-compiled list-pro cessing language. Journal of th e ACM 7 (2), 87–101 (1960 ) 16. Goldb erg, B.: T ag-free garbage collection for strongly typed programming lan- guages. In: PLDI ’91, pp. 165–176. ACM Press (1991) 17. H irzel, M., Diwan, A., Henkel, J.: On the usefulness of type and liveness accuracy for garbage collection and leak detection. ACM T ransactions on Programming Languages and S ystems 24 (6), 593 –624 (2002) 18. Kh edker, U.P ., San yal, A., Kark are, A.: Heap reference analysis using access graphs. ACM T ransactions on Programming Languages and Systems 30 (1), A rticle 1 (2007) 19. Ku ng, H.T., Song, S.W.: An efficien t parallel garbage collection system and its correctness pro of. In: FOCS 1977, p p. 120–131. IEEE Computer So ciety Press (1977) 20. Lieb erman, H., Hewitt, C.: A real-time garbage collector based on the lifetimes of ob jects. Communicatio ns of th e ACM 26 (6), 419–429 (1983) 21. McCarthy , J.: R ecursive functions of symbolic expressions and their computation by mac hine. Communications of the AC M 3 (4), 184–1 95 (1960) 22. Minsky , M.L.: A LISP garbage collector algo rithm using serial secondary storag e. Memo 58 ( Revised), Pro ject MAC , Mass ach usetts Institute of T ec hnology (1963) 23. S annella, D., T arlec ki, A.: Algebraic preliminaries. In : E. Astesiano, H.J. Kreo wski, B. Krieg-Br ¨ uckner (eds.) Algebraic F ound ations of Systems Sp ecification, pp. 13– 30. Springer-V erlag , Berli n (1999) 24. S c horr, H., W aite, W.: An efficient machine-indep endent p rocedu re for garbage collection in v arious list structu res. Comm unications of the ACM 10 (8), 501–50 6 (1967) 25. S haham, R., Kolod n er, E.K., Sagiv, M.: On eff ectiveness of GC in Jav a. In: ISMM ’00, pp. 12–17. AC M Press (2000 ) 26. S haham, R ., Kolo d ner, E.K., Sagiv, M.: Heap p rofiling for space-efficient Jav a. ACM SIGPLAN Notices 36 (5), 104–113 (2001) 27. S haham, R., Y aha v, E., Kolodn er, E.K., Sagiv, M.: Establishing local temp oral heap safet y prop erties with applications to compile-time memory management. Science of Computer Programming 58 (1–2), 264–289 (2005) 28. S teele Jr., G.L.: Multiprocessing compactifying garbage collection. Comm unica- tions of the AC M 18 (9), 495–5 08 (1975) 29. Wirsing, M.: Algebraic sp ecification. In: J. v an Leeuw en (ed.) Handb o ok of Theo- retical Computer Science, vol. B, pp . 675–788 . Elsevier, Amsterdam (1990) 22
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment