Each C module using BIP must include the file bip.h
.
respectively give the logical number of the current process and the total number of processes.
this is an asynchronous receive call. tag identifies the receive queue on which this call applies, buf gives the target buffer where the message will be stored at completion, maxlength is the maximum size the buffer is able to receive. The first message that arrives (or has already arrived) for this queue from the network will go into this buffer, it is an error if a message longer than this size arrives. The buffer contents are invalid until completion (as told by bip_rwait), and should not be modified until that. This function returns an identificator that should be passed to bip_rwait. This function returns immediately but you cannot do any other recv or irecv call with the same tag until the receive has completed (so after calling bip_rwait/bip_rtest).
It is a non-blocking receive, if a short message
is ready on the queue given by tag,
it does not block and is equivalent to bip_trecv
, else it is a
``no-op'' call and returns -1 (not zero because that is a
valid message size). Warning: you cannot receive a long
message with this call: it will always return -1 if a long message is
arriving to the head of the queue
This function receives a message on queue tag and returns a pointer to the contents (the message is in a statically allocated buffer), the message size is returned via the parameter length, and the source of the message is returned in node. When the user has finished using the message contents, it must free it explicitely via bip_tfreemsg(tag).
similar to bip_tgetmsg except it is non-blocking. If no message is available, it returns a null pointer and has no side-effect.
Allows to override the default buffer size allocated to the queue specified by tag, the buffer will be able to store nbufs messages of length size without any receive occuring. If the message are smaller, they can be more of them. But note that you have to take into account for each message not only the payload but also a few words (currently 4) of head information for internal purpose. This procedure can be called at most one time for each queue, and it must be called before the bip_init function. This procedure is optional, default values are taken, if not explicitely defined.
The following functions can be semantically defined in terms of the previous one. They are provided both for convenience and also because their implementation is sometimes faster that using the basic primitives of BIP.
blocking receive, semantically equivalent to bip_rwait(bip_tirecv(tag,buf,maxlength).
blocking receive, semantically equivalent to bip_rwaitx(bip_tirecv(tag, buf,maxlength).
blocking send, semantically equivalent to bip_swait(bip_tisend(dst, tag, buf,length).
There exists an ``untagged'' version of all BIP calls to maintain compatibility with previous versions, and for convenience for applications that just need one queue.
The functions are:
equivalent to bip_trecvx(0,buf,maxlength,node)
equivalent to bip_tsend(dst, 0, buf,length).
Note that a bip_tirecv must be followed by a bip_rwait/bip_rtest. On the other hand, the bip_swait/bip_stest is not mandatory after a bip_tisend, but you should not reuse the buffer or issue another send before you are sure the message has been received at the other side (for example because you have received an answer).
Note that in the current implementation, passing a value of maxlength much larger than the final message length can have a significant impact on performance.