next up previous

3.1 C Example

Figure 1 gives the C code for the master program which is contained in the file master.c. Figure 2shows the C code for the worker portion of the PVM example application stored in the file worker.c. Let's examine each program to see how the PVM calls are used.

Figure 1: C version of master example.

Figure 2: C version of worker example.

The first line of both programs includes the PVM header file. This file gives definitions to PVM symbolic names and functions. If PVM is available in a system directory, this header file will be installed as well. Consult with the system administrator for the proper directory.

The first PVM call in the master program informs the PVM daemon of its existence by enrolling the task in the virtual machine. The function pvm_mytid() is used for this purpose and assigns a task id to the calling task.

int tid = pvm_mytid()
The result returned is the assigned task id. There is no parameter to this function.