Newsgroups: comp.parallel.pvm
From: "M. Niemann" <niemann@parallel.fh-bielefeld.de>
Subject: Re: pvm_getfds()
Organization: Fachhochschule Bielefeld, Germany
Date: Wed, 6 Nov 1996 14:23:02 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <32809F46.595F2D52@parallel.fh-bielefeld.de>

Ulisses T. Mello wrote:
> 
>         Where I can find documentation about the function pvm_getfds() mentioned
> in the faq # 5.6?
> 

Hello !

Have a look at the man-page:

GETFDS(3PVM)      Misc. Reference Manual Pages       GETFDS(3PVM)

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 com-
     plete 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.


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);


Sun Microsystems    Last change: 22 Nov, 1994                   1






GETFDS(3PVM)      Misc. Reference Manual Pages       GETFDS(3PVM)



          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.

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

SEE ALSO
     pvm_notify(3PVM), pvm_trecv(3PVM)


Sun Microsystems    Last change: 22 Nov, 1994                   2


-- 
Marcus Niemann			  niemann@parallel.fh-bielefeld.de
Labor fuer Parallelverarbeitung   Fachhochschule Bielefeld

