The TakTuk communication layer interface library provides a way for programs executed using the taktuk(1)
command to exchange data. It is based on a simple send/receive model using multicast-like sends and
optionally timeouted receives. This is only designed to be a control facility, in particular this is not
a high performance communication library.
Any program using TakTuk C communication interface has to link his program to the "taktuk" and "pthread"
libraries (the "taktuk" library is provided with the distribution). Headers for communication functions
and constants definitions can be found in "taktuk.h" also provided with the distribution.
The communication functions are:
miscellaneousfunctionsinttaktuk_init_threads();inttaktuk_leave_threads();
functions to be called once in the process respectively before threads creation and after threads
destruction if you want TakTuk C interface to be thread-safe.
Nevertheless, notice that, because of the way TakTuk is implemented, the handling of "recv" functions
in several threads is completely sequentialized. This is especially important regarding timeouts: if
a timeout is given to a "recv" function, it will only be started at the calling thread's turn. In
other words, issuing multiple timeouted "recv" in several threads of the same process might result in
timeouts longer that expected (they become at most the sum of all pending "recv" timeouts).
inttaktuk_get(constchar*field,unsignedlong*result);
gets some information from TakTuk and places it into result. Currently available information are
"target", "rank", "count", "father", "child_min" and "child_max". This is a better way to get these
information than environment variables as its takes into account renumbering that might occur after
process spawn.
multicastsendfunctionsinttaktuk_multi_send(constchar*dest,constchar*target,constvoid*buffer,size_tlength);inttaktuk_multi_sendv(constchar*dest,constchar*target,conststructiovec*iov,intiovcnt);
"taktuk_multi_send" sends the content of "buffer" made of "length" bytes to the set of target
processes "target" present on the set of destinations "dest" (nul terminated characters strings, see
taktuk(1) for information about set specifications for destination hosts and target processes).
"taktuk_multi_sendv" is the vector variant of "taktuk_multi_send" (similar to "writev" system
function).
singlehostsend/recvfunctionsinttaktuk_send(unsignedlongdest,unsignedlongtarget,constvoid*buffer,size_tlength);inttaktuk_sendv(unsignedlongdest,unsignedlongtarget,conststructiovec*iov,intiovcnt);
sends the content of "buffer" made of "length" bytes to process "target" on the host "dest" (see
taktuk(1) for more information about target processes). In this case, the target value might also be
TAKTUK_TARGET_ANY to target the first process performing a "recv", TAKTUK_TARGET_ALL to target all
processes, or TAKTUK_TARGET_OUTPUT to target the "message" stream rather than a process.
"taktuk_sendv" is the vector variant of "taktuk_send" (similar to "writev" system function).
inttaktuk_recv(unsignedlong*from,void*buffer,size_t*length,structtimeval*timeout);inttaktuk_recvv(unsignedlong*from,conststructiovec*iov,intiovcnt,structtimeval*timeout);
blocks until the reception of a message. If a regular message is received, "taktuk_recv" sets the
value of its arguments: "from" to the logical number of the sender, "buffer" to the data received
which is made of "length" bytes. If timeout is not NULL, taktuk_recv() might receive a timeout
notification. In this case, taktuk_recv() returns the TAKTUK_ETMOUT error code. "taktuk_recvv" is
the vector variant of "taktuk_recv" (similar to "readv" system function).
WARNING: the buffer size should be sufficient to receive all the data of the matching send. If this
is not the case, the program is likely to end up abruptly with a segmentation fault.
low-levelrecvfunctionsinttaktuk_wait_message(unsignedlong*from,size_t*size,structtimeval*timeout);inttaktuk_read(void*buffer,size_tlength);inttaktuk_readv(conststructiovec*iov,intiovcnt);
"taktuk_wait_message" waits for a taktuk message to be available and sets "from" to the logical
number of the sender and "size" to the size of the received message. It must be followed by a call
to either "taktuk_read" or "taktuk_readv" to read the data (using the size given by
"taktuk_wait_message"). As other TakTuk receive functions, this function might return the
TAKTUK_ETMOUT error code if "timeout" is not NULL and expires before the reception.
If you don't know in advance the size of the data being sent to you, you can use these lower level
functions. Actually, "taktuk_recv" is equivalent to a call to "taktuk_wait_message" followed by
errors checks on buffer size and a call to "taktuk_read". This is the same for "taktuk_recvv".