|
NAMEpvm_putinfo, pvm_recvinfo, pvm_getmboxinfo, pvm_delinfo - Store and retrieve messages in global mailbox.SYNOPSISC int index = pvm_putinfo( char *name, int bufid, int flags ) PARAMETERS
DESCRIPTIONThese functions implement a "message mailbox" database that can be used by PVM tasks to advertise information to other PVM tasks. An example would be to advertise names or locations of services. Another example would be to advertise a common "context" on which two tasks may communicate.The database entries are PVM messages keyed by a user specified name and an optional index value. The name may be any null-terminated string and the index a non-negative integer. The index value is assigned by PVM and is used to uniquely identify one of multiple named instances within the database. Entries are "owned" by the task that created them. An entry is automatically removed from the database when the owner task exits unless the database entry was created with flag PvmMboxPersistent. When a task exits and leaves an entry in the mailbox, the owner tid of that entry is marked as zero (0) to indicate that there is no longer an active owner task. pvm_putinfo inserts a record in the database, given a key and data (message). It returns mailbox index number if the record is successfully stored, PvmExists if a record with the given key already exists, or PvmDenied if an attempt is made to overwrite a locked record. The following options are added together as the flags parameter to pvm_putinfo.
pvm_recvinfo operates just like a pvm_recv() except the message is coming from the database. The message should be unpacked after pvm_recvinfo(). Like pvm_recv, pvm_recvinfo returns a pointer to a message buffer containing the record matching the key <name,index> from the database. Returned value < 0 indicates an error. The following options are added together as the flags parameter to pvm_recvinfo.
pvm_delinfo deletes database entry specified by the key <name, index>. Returns PvmOK if the record was deleted, PvmNotFound if the record does not exist, or PvmDenied if an attempt is made to remove a "locked" record. There are no flags presently specified for pvm_delinfo. pvm_getmboxinfo returns an array of pvmmboxinfo for all class names in the database. This is used, for example, by programs that clean up the database or for applications to find out what is available. classes returns a pointer to the array allocated by libpvm and freed on the next call to pvm_getmboxinfo. The Fortran function returns information on one entry per call. Thus, if called repeatedly until an info value of PvmNotFound is returned, all entries matching the given pattern will have been returned. If a new pattern is desired, calling pvmfgetnames() with info = -1 will reset the entry name list and obtain a new list for the given pattern. EXAMPLESC: /* * create and insert mailbox entry */ sprintf( service, "Task_A_service" ); sprintf( message, "Greetings from task A." ); pvm_initsend( PvmDataDefault ); pvm_pkint( &mytid, 1, 1 ); pvm_pkint( &context, 1, 1 ); pvm_pkstr( message ); if (( pvm_putinfo( service, pvm_getsbuf(), PvmMboxDefault )) == PvmExists ){ printf( "can't register - service already running0 ); exit( -1 ); } /* * look for and retrieve specified mailbox */ sprintf( service, "Task_A_service" ); if (( msg_buf = pvm_recvinfo(service, 0, PvmMboxFirstAvail )) >= 0 ){ pvm_setrbuf( msg_buf ); pvm_upkint( &their_tid, 1, 1 ); pvm_upkint( &their_context, 1, 1 ); pvm_upkstr( message ); } Fortran: we need the fortran examples... ERRORSThe following error conditions can be returned by one or more of these functions:
SEE ALSOpvm_initsend(3PVM), pvm_getsbuf(3PVM), pvm_pack(3PVM),
Visit the GSP FreeBSD Man Page Interface. |