Elementos de la Psicología del Desarrollo
89 C Desarrollos actuales
B. Afirmación primordial y asentimiento subjetivo
careful not to call either ¡HakcEschisivel or IHakePublicj twice in succession (one would use safer procedures in the real implementation). The procedures are:
PROCEDURE M k s E x c l u . l v . (semaphore : ACTOR) ;
BEGIN : R !
SEND DATON TO (s e m a p h o r e ) ; END ;
PROCEDURE BEGIN
M k s P u b l i e (semaphore ACTOR) ; : R ! SEND DATON TO (s e m a p h ore) ; END ;
!
4.6.3 Data Structuras and Initialisation of fcOPYl
A sizeable bank of information is accessed by the inport and each outport of
[COPY, and by procedures within them. Most of the state information of the inport
and each outport can be grouped into data records (PASCAL'S device for constructing data structures), which we call descriptors. This makes in particular the parameter passing much simpler. Here is the type declaration for our descriptors
I V . 81
TYPE
OUTPORTSTRUCT = RECORD ( * T h e r e i a one o f t h e e e p e r COPY o u t p o r t . • )
o a c t o r ACTOR ( • A c t o r name o f t h i s o u t p o r t . * )
b u f f e r CE LLP ( * Daton b u f f e r p o i n t e r . • )
n o v a lu e * INTEGER ( • How many l e a d i n g d a to n s s h a l l be i g n o r e d • ) o i nde s INTEGER ( • C u rr e n t d ato n index ( f r o m l a s t ADVANCE). * ) w a i t i n g END ; BOOLEAN ( * S t a t e i n d i c a t o r f o r i n p o r t . • ) INPORTSTRUCT = RECORD ( • I n p o r t d e s c r i p t o r : ♦ ) i a c t o r ACTOR ( • A c t o r name o f t h i s i n p o r t . * ) t a i l c e l l CELLP ( * P o i n t e r t o t a i l o f d a t o n b u f f e r . • )
i index INTEGER ( • C u rr e n t d ato n ind ex. • )
( * i i n d e x = in d e x o f n e x t d a to n t o be r e c e i v e d . * )
C = in d e x a i o f d ato n in t a i l c e l l . * )
a c t i v e INTEGER ( • Number o f o u t p o r t s n o t f i n a l index * )
p r o f i t ing INTEGER ( • Number o f o u t p o r t s w i t h n o v a lu e s = 0 • )
customers INTEGER ( * Number o f o u t p o r t * w i t h : • )
( • o u t p o o l [ i ] w a i t i n g = TRUE * ) pO ACTOR ( • Operand a c t o r . • ) semaphore ACTOR n o u t p o r t s INTEGER ( • Number o f o u t p o r t s . » ) o u tp o o l END ; ARRAY [1 ■ n o u t p o r t » ] OF OUTPORTSTRUCT ;
The current /nport index [Undexl refers to the daton presently due to reach the inport, the current Outport index ¿¡index] refers to the daton presently due to come out of the respective outport. (A real programming language would hardly permit a dynamic array as an element of a data record, such as foutpooll above However, every implementor knows alternative ways for achieving the same effect.) In procedure headings, we will repeatedly encounter formal parameters of the kind:
[VAR outport : OUTPORTSTRUCTj
When looking up the corresponding actual parameters it will always turn out that [outportI is merely an alias for ioutpooiltll, which m turn is an array element within lINPORTSTRiXTl, i is outport dependent.
The ftNPORTSTftUCTl and all the various ioir?0R::lsrRDcfl of the entire Ico'PYl node actor get initialised when the inport actor calls the procedure ilmtmliaeCoprl:
IV . 62 PROCEDURE I n i t i a l I » . C o p y ( n e t c r e a t o r : ACTOR ; VAR i n p o r t : INPORTSTRUCT) ; VAR i : INTEGER ; BEGIN WITH i n p o r t DO BEGIN p r o f i t i n g ; = n o u t p o r t s ; customers : = 0 ; a c t i v e : « n o u t p o r t s ; i i n d e x : = 0 ; t a i l c e l l : = N IL ; semaphore := CREATE ( A c t . G u a r d i a n _ ) ; FOR i : = l TO n o u t p o r t s DO WITH o u t p o o l [ i ] DO BEGIN o a c t o r := CREATE ( A c t _ C o p y O u t p o r t _ , i n p o r t , o u t p o o l [ i ] ) ; SEND (DATON, o a c t o r ) TO ( n e t c r e a t o r ) ; b u f f e r ; * NIL i oin d ex : = 0 ; w a i t i n g = FALSE ; no v alu e s 0 ; END ;
( , , pO) ;= RECEIVE FROM ( n e t c r e a t o r ) ;
END END ; ( • I n i t i a 1iseCopy •)
4.6.4 Raquict Propagation, and Voting
We m entioned in section 4.2 the two d ia m etrica lly o p p o sed s tra te g ie s which govern the propagation of requests. I COPY; issues a [COMPUTE; re q u e s t w h en ever any of its outports needs the daton value without th e daton having b e e n b u ffe re d yet. A fte r the ¡COMPU~£|. a cou n teractin g ! NULLIFY! may be sent if the d a to n evalu ation p ro ves superfluous. ICOPYl sends an iADVANCE] as soon as it has a c c e p te d the d a to n valu e fo r the daton buffer.
On the other hand, an outport can get many bare ADVANCE requests in a row. Such requests may eventually put the outport into the o ff-c h a in state. Wo like to propagate 'ADVANCE! requests, in general, at the earliest possible moment, since they are capable of releasing buffer space in fcoPVl nodes "further upstream" in the Lucid graph. However, any I ADVANCE I can be propagated only if there will be definitely no subsequent demand for the current daton. jcoEVI can therefore propagate I advance] only when (the daton buffer is empty and) each outport has surrendered its claim for the current daton. Each time [COPY! obtains a new daton (and its cell has been
IV . 63 appended to the tail end of the chain) it checks whether the chain has now caught up with any of the off-chain outports If appropriate, the outport is then hooktd in at the chain tail.
Every ¡ADVANCE, flaaliadesl puts the outport into flnaiindex-stafte, and the finalindex-state implies off—chain state. Once an outport enters the finalindex—state it withdraws all further claims to datons. All the rules about I ADVANCE! have to be extended accordingly to this special ¡ADVANCE!. The effect of ;CODV| receiving an I ADVANCE, finalindeil is usually tantamount to receiving infinitely many bare IADVANCE1. Occasionally, it may lead to the propagation of many I ADVANCE! requests; this would be due to the WHILE! loop in! [ncrerrentNovaiueal.
The jADVANCE! propagation is implemented in ¡COPY; by what is essentially a vote
counting where all decisions have to be unanimous. Each outport records in a cell
(named nov.iu««;) by how many datons it has advanced beyond the current inport daton. The inport records in a cell ¡profiling! how many of its outports might benefit from knowing the value of the current daton, I.e. how many of its outports have Inovaiu«»! as 0. So, ¡prof, ting I is decremented whenever an outport increases its j novaHe»! from 0 to 1, and vice versa. Once all |novaiue«ii are greater than zero (i.e. once [profiting! = 0) an I ADVANCE! can be propagated to the operand actor After every Increment of 'iindegj, like now, all positive Inovaiue»! can be decremented Most of what is described in this paragraph is carried out by the procedure Hnt-rementNovaluci] (t 4.8 7) The procedure IbecrementNoraiuei] performs obviously the inverse task
4.6.6 Despair and the ‘Trojan Horsa"
The ¡COPY! node actor propagates, by design, only the l* a »t tx p tn s iv * request for getting the job done. However, situations can arise where wasteful computations are hard to avoid in pipeline DF. l,et us consider a ¡COPY! node with 2 active outports named X and Y. and we are at the beginning of program execution. Outport Y
I V - 64