|
Channels <chan.h> |
Top Previous Next |
|
The functions described here allow programs to access the basic communication facility of the Diamond model, which is to transfer a message across a channel.
The header chan.h defines the following:
The chan.h functions must always include in their parameter list the address of a channel. This could be the address of a user-declared variable of type CHAN.
For example:
CHAN mychan; int value; chan_init(&mychan); ... chan_out_word(value, &mychan);
Alternatively, it could be a port:
int main(int argc, char *argv[], char *envp[], CHAN * in_ports[], int ins, CHAN *out_ports[], int outs) { int value; ... chan_out_word(value, out_ports[0]); ... }
Note that the channels passed in through the port vector arguments of main must not be initialized; all others, such as mychan above, must be initialized by calls to chan_init.
The functions provided in chan.h are listed below. Messages of any type and size can be transmitted by the two general-purpose functions chan_in_message and chan_out_message. The word functions are simply convenient shorthands for four-octet messages.
Note that most inter-processor links support only transfers that are multiples of 4 octets.
|