return to first page linux journal archive
keywordscontents

Listing 2. PVM Timing Slave Program

/****************************************************
* PVM Timing - Slave Program, File: slave_tim.c
* PVM Version used: 3.3.x
* Comment: This file is an adaptation of one 
* packaged with the PVM source.
*****************************************************

#include "pvm3.h"	/* PVM version 3.0 include
				 * file */

main() {
	int mytid;	/* PVM process task id */
	int parent;	/* PVM process task id for
			 * parent */
	int ret_int[10];	/* a return message */
	int stid, stag, slen;	/* parameters needed
				 * by pvm_precv */
	int i;	/* loop index */

	/* enroll worker task in PVM machine */
	mytid = pvm_mytid();
	/* get task ID of parent/master process */
	parent = pvm_parent();

	/* wait for message master */
	pvm_precv(parent, 1, ret_int, 10, PVM_INT, 
		&stid, &stag, &slen);

	/* this loop time will be included in the 
	 * master's delta_t */
	for (i=0; i<10; i++)
	  ret_int[i] = 2*ret_int[i];
	 <\n> 
	/* send reply back to master */
	pvm_psend(parent, 2, ret_int, 10, PVM_INT);

	/* exit from PVM */
	pvm_exit();
	exit(0);
       <\n> 
}