Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

CentOS 2.1AS

(Slurm)

pvm_getfds(3)


GETFDS

GETFDS

NAME
SYNOPSIS
PARAMETERS
DESCRIPTION
RESTRICTIONS
EXAMPLES
ERRORS
SEE ALSO

NAME

pvm_getfds − Get file descriptors in use by PVM.

SYNOPSIS

C

int nfds = pvm_getfds( int **fds )

Fortran

Not Available

PARAMETERS

fds

Returns integer array of file descriptors.

DESCRIPTION

A PVM task uses sockets to communicate between libpvm and other tasks or the pvmd. It is sometimes useful to know the file descriptor numbers of the sockets in order to wait from input from either PVM messages or an external source. For example, the PVM console waits on both keyboard input and notify messages. Input can be multiplexed by polling all sources, but this wastes cpu cycles. Instead, the select() system call can be used to wait until one or more sources of input are ready.

If it completes successfully, pvm_getfds returns the number of sockets in use, and the file descriptor numbers in an array (allocated and freed by libpvm). At least one socket always exists (from task to pvmd), and its descriptor is always fds[0]. The number of sockets varies as direct routes are established to other tasks.

It can be difficult to track the set of file descriptors if direct routing is enabled, because routes are created as messages are either sent or received. The simplest approach is to disable direct routing.

When select returns with a PVM file descriptor ready, a complete message may be ready to be received, or instead only a fragment may be waiting. pvm_nrecv or pvm_probe should be used test without blocking.

RESTRICTIONS

pvm_getfds is only available when running PVM on a Unix or similar system.

EXAMPLES

The following program fragment waits until either keyboard input is available, or a PVM message has arrived.

int *d;

fd_set r;

pvm_setopt(PvmRoute, PvmDontRoute);

pvm_getfds(&d);

FD_ZERO(&r);

FD_SET(0, &r);

FD_SET(d[0], &r);

while (1) {

if (select(d[0] + 1, &r, (fd_set*)0, (fd_set*)0,

(struct timeval*)0) > 0) {

if (FD_ISSET(0, &r))

... /* read keyboard input */

if (FD_ISSET(d[0], &r) && pvm_nrecv(-1, -1) > 0)

... /* got a PVM message */

}

}

ERRORS

The following error condition can be returned by pvm_getfds:
PvmSysErr

pvmd not responding.

SEE ALSO

pvm_notify(3PVM), pvm_trecv(3PVM)



pvm_getfds(3)