Channels



next up previous contents index
Next: Nondeterminism Up: Fortran M Language Previous: Concurrency

Channels

 

Processes communicate and synchronize by sending and receiving values on typed communication streams called channels. A channel is created by a CHANNEL  statement, which also defines the supplied inport and outport to be references to the new channel. A channel is a first-in/first-out message queue. An element is appended to this queue by applying the SEND  statement to the outport that references the channel. This statement is asynchronous: it returns immediately. An element is removed from the queue by applying the RECEIVE  statement to the inport that references the channel. This statement is synchronous: it blocks until a value is available. The ENDCHANNEL  statement appends an end-of-channel (EOC) message to the queue. The MOVEPORT  statement copies a channel reference from one port variable to another.

These statements all take as arguments a control information list (cilist). The optional IOSTAT= , END= , and ERR=  specifiers have the same meaning as the equivalent Fortran I/O specifiers, with end-of-channel  treated as end-of-file, and an operation on an undefined port treated as erroneous. An implementation should also provide, as a debugging aid, the option of signaling an error if a SEND , ENDCHANNEL , or RECEIVE  statement is applied to a port that is the only reference to a channel.

SEND (cilist) E,...,E
Add the values E, ..., E (the sources) to the channel referenced by the outport named in cilist (the target). The source values must match the data types specified in the port declaration, in number and type.

RECEIVE (cilist) V,...,V
Block until the channel referenced by the inport named in cilist (the target) is nonempty. If the next value in the channel is not EOC, move values from the channel into the variables V, ..., V (the destinations). The destination variables must match the data types specified in the port declaration, in number and type.

ENDCHANNEL (cilist)
Append an EOC message to the channel referenced by the outport named in cilist.

MOVEPORT (cilist)
Copy the value of the port specified ``from'' in cilist (the source) to the port specified ``to'' (the target), and set the source port to undefined.

A port is initially undefined. An undefined port becomes defined if it is included in a CHANNEL  (or MERGER : see below) statement, if it occurs as a destination in a RECEIVE , or if it is named as the target of a MOVEPORT  statement whose source is a defined port. Any other statement involving an undefined port is erroneous.

Application of the ENDCHANNEL  statement to an outport causes that port to become undefined. The corresponding inport remains defined until the EOC message is received by a RECEIVE  statement, and then becomes undefined. Both inports and outports become undefined if they are named as the source of a SEND  or MOVEPORT  operation.

Storage  allocated for a channel is reclaimed when both (a) either the outport has been closed, or the outport goes out of scope or is redefined, and (b) either EOC is received on the inport, or the inport goes out of scope or is redefined.

 



next up previous contents index
Next: Nondeterminism Up: Fortran M Language Previous: Concurrency



Steve Tuecke
Tue Aug 30 12:20:34 CDT 1994