next up previous

3.1 C Example     continued...

After the program is enrolled in the virtual machine, the master program initializes the data that is to be summed up. Next, the worker processes are spawned. The function to spawn worker processes is pvm_spawn().

int numt = pvm_spawn( char *task, char **argv, int flag, 
char *where, int ntask, int *tids)

The first parameter is a string containing the name of the executable file that is to be used. Any arguments that must be sent to this program are in an array pointed to by argv. If no arguments are required by the task, then the argv parameter is NULL. The flag parameter is used to determine the specific machine or type of architecture the spawned task is to be run on. Possible values for flag are:

These symbolic names are defined in the PVM include file pvm3.h.

The fifth parameter, ntask, specifies the number of copies of the task to be spawned and tids is a pointer to an integer array that returns the task ids of all tasks spawned. The function returns the number of tasks that were successfully created. If some tasks could not be started, the last ( ntask - numt) positions of tids will contain error codes for the unsuccessful tasks.