TakTuk - Perl module that provides an interface to taktuk(1)
communication
facilities
use TakTuk; my $rank = TakTuk::get('rank'); my $count = TakTuk::get('count'); print "I'm process $rank among $count\n"; if ($rank > 1) { my ($to, $from, $message) = TakTuk::recv(); if (not defined($message)) { print "Trying to recv: ", TakTuk::error_msg($TakTuk::error), "\n"; } else { print "$to received $message from $from\n"; } } sleep 1; my $next = $rank+1; $next = 1 if ($next > $count); if (not TakTuk::send(to=>$next, body=>"[Salut numero $rank]")) { print "Trying to send to $next: ", TakTuk::error_msg($TakTuk::error), "\n"; } if ($rank == 1) { my ($to, $from, $message) = TakTuk::recv(timeout=>5); if (not defined($message)) { print "Trying to recv :", TakTuk::error_msg($TakTuk::error), "\n"; } else { print "$to received $message from $from\n"; } }
The TakTuk communication layer Perl interface 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.
WARNING: the TakTuk communication interface is not process-safe : it is probably a very bad idea to use point-to-point communication in more than one process related to a single TakTuk instance (these processes might be several local commands or forked processes).
The Perl communication interface for TakTuk is made of functions that can be
called by scripts executed using the taktuk_perl
command of the TakTuk
engine (prefered way, less installation requirements on remote machines) or
using the TakTuk Perl module provided with the TakTuk distribution.
These functions are:
gets some information from TakTuk. Currently available informations are 'rank', 'count', 'father', 'child_min' and 'child_max``. This is a better way to get these informations than environment variables as its takes into account renumbering that might occur after process spawn.
sends a scalar to a single peer or a set specification (see taktuk(1)
for
informations about set specifications).
The two mandatory fields in the arguments are to
(with a set specification)
and body
. Returns an undefined value upon error.
blocks until the reception of a message. Returns a list of three elements: the
logical number of the destination of the message, the logical number of its
source and the message itself.
Accepts an optional timeout
argument with a numeric value.
Returns an empty list upon error.
When an error occur, both of these functions set the variable $TakTuk::error
to the numeric code of the error that occured. A textual description of the
error is provided by the function TakTuk::error_msg($)
that takes the error
code as an argument.
Error codes are the following :
a call to TakTuk::syswrite
failed. This is due to a syswrite
error
different than EAGAIN
. The code should be accessible using $!
.
the communication channel to the TakTuk engine has been closed. This typically occur when shutting down the logical network (using Ctrl-C on root node for instance).
TakTuk::recv
only)
a call to sysread
failed (the code should be accessible using $!
).
TakTuk::send
only)
to
field missing in the arguments.
TakTuk::send
only)
body
field missing in the arguments.
TakTuk::recv
only)
The call to TakTuk::recv
timeouted. This only occur when giving a timeout
field as TakTuk::recv
argument.
tatkuk(1)
, taktukcomm(3)
, TakTuk::Pilot(3)
The original concept of TakTuk has been proposed by Cyrille Martin in his PhD thesis. People involved in this work include Jacques Briat, Olivier Richard, Thierry Gautier and Guillaume Huard.
The author of the version 3 (perl version) and current maintainer of the package is Guillaume Huard.
The TakTuk
communication interface library is provided under the terms
of the GNU General Public License version 2 or later.