chan...

Top  Previous  Next

chan_init

#include <chan.h>

void chan_init (

   CHAN *chan

);

stand-alone

This function initializes the channel pointed to by its chan argument, so that it indicates that no threads are currently attempting to communicate through this channel. All channel objects (i.e., all variables declared to be of type CHAN) must be initialized before the first attempt to communicate through them. If this is not done, the first attempt to communicate through the channel will cause the processor to crash. You must not use chan_init on a channel that is actively being used for a transfer.

 

Dragons003chan_init must not be used on any channel connected as the result of a CONNECT or BIND statement in the configuration file. Such channels are those declared in the parameters to main or using the INPUT_PORT and OUTPUT_PORT macros. The channel objects bound to a program's input and output ports are already initialized by the calling environment, and should not be initialized again by the program.

chan_in_message

#include <chan.h>

void chan_in_message (

   int   len,

   void *buf,

   CHAN *chan

);

stand-alone

stack: 80 bytes

This function reads a message of length len octets (eight-bit bytes) from the channel pointed to by chan into the variable pointed to by buf. The function waits if the other end of the channel is not attempting to write.

Dragons003The value of len must be greater than zero and a multiple of 4; buf must be word-aligned.

chan_in_word

#include <chan.h>

void chan_in_word (

   int  *w,

   CHAN *chan

);

 stand-alone

stack: 80 bytes

This function reads a word-length message from the channel pointed to by chan into the integer variable pointed to by w. The function waits if the other end of the channel is not attempting to write.

chan_out_message

#include <chan.h>

void chan_out_message (

   int   len,

   void *buf,

   CHAN *chan

);

stand-alone

stack: 80 bytes

This function sends a message of length len octets (eight-bit bytes) from the variable pointed to by b to the channel pointed to by chan. The function waits until all data have been sent. For physical transfers over links, the function returns when all data have been sent to the output device; the receiver may not have read all the data at this point. For local and virtual channels, the call blocks until the receiver has read all the data.

Dragons003The value of len must be greater than zero and a multiple of 4; buf must be word-aligned.

chan_out_word

#include <chan.h>

void chan_out_word (

   int   w,

   CHAN *chan

);

stand-alone

stack: 80 bytes

This function sends a word-length message consisting of the value w to the channel pointed to by chan. The function waits until the word has sent. For physical transfers over links, the function returns when the word has been sent to the output device; the receiver may not have received the word at this point. For local and virtual channels, the call blocks until the receiver has read the word.

chan_reset

#include <chan.h>

THREAD_HANDLE chan_reset (

   CHAN *chan

);

 stand-alone

Dragons003You should use chan_reset only with extreme caution and avoid using it on internal or virtual channels.

 

chan_reset puts a channel back to its initial state and returns the handle of any thread waiting on the channel, or zero if no thread is waiting. The waiting thread is now effectively dead.

 

The only significant use of this function is when a physical channel is known to be associated with a link. In this case, the effect is to empty any FIFOs associated with the device and return 0. Note that all FIFOs associated with the device are flushed; resetting an output channel also flushes any incoming FIFO and vice versa.