Concepts+Techniques+and+Models+of+Computer+Programming_Part29

Concepts+Techniques+and+Models+of+Computer+Programming_Part29

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
798 Language Semantics Having just one operation to use cells, Exchange , is rather minimal. It is often convenient to assume that two other operations exist, namely x c := x (assignment) and x =@ x c (access). Since we can define them in terms of Exchange , no additional rules are needed for them. It is interesting to see the dataflow behavior of Exchange . It blocks until its first argument references a cell. It never blocks on the second or third arguments. This allows it to manipulate the cell’s contents even before they are determined. Example of a stream Using cells and dataflow variables together permits some remarkable program- ming techniques. We give a small example that uses a stream. Assume that the cell C contains the tail of a stream. Then the following statement adds the atom one to the stream: local X Old New in {Exchange C Old New} X=one Old=X|New end The three instructions inside this local statement can be executed in any order and the final result is exactly the same. What’s more, several threads can inde- pendently add elements to the stream by each executing this local statement. The order of the elements on the stream is determined by the order in which the Exchange statements are executed. 13.1.13 By-need triggers The by-need trigger is the basic concept used to define demand-driven execution. Its semantics is carefully designed so that the demand-driven concurrent model is still declarative. We define the semantics in two steps. We first define the need σ ( S, x )re la t iontha tsay swhens ta temen t S “needs” variable x .W et h e n define the semantics of the ByNeed operation. For this, we add two predicates to the store, namely ( x )and trig ( p, x ). We can view these as sitting in a new store called the trigger store . The semantics of Section 4.5.1 is correct according to this section, but the semantics of this section is more general (it allows more executions). Section 4.5.1 is more restricted to make it easier to implement. The by-need semantics of this section is designed so that the demand-driven concurrent model of Chapter 4 is declarative. In particular, the semantics is designed so that the ( x ) predicate is monotonic, reduction rules for by-need triggers introduce no nondeterminism, and unification never blocks because of by-need execution. Copyright c ± 2001-3 by P. Van Roy and S. Haridi. All rights reserved.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
13.1 The shared-state concurrent model 799 The need σ ( S, x ) relation The relation σ ( S, x ) holds between a statement S ,astore σ , and a variable x if and only if three conditions hold: No reduction is possible for S with store σ . There exists a constraint c (a set of variable bindings) such that σ c is consistent and a reduction is possible for S with store σ c . It is true that σ | = ¬ det ( x ) and for all constraints c that satisfy the previous condition, we have σ c | = det ( x ).
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 08/10/2011.

Page1 / 30

Concepts+Techniques+and+Models+of+Computer+Programming_Part29

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online