next up previous

3.1 C Example     continued...

In our example code five (NPROCS) copies of the executable file ``worker'' will be spawned by the master program. No arguments are to be sent and we are allowing PVM to choose which machines will be used to execute the worker code. The task ids will be placed in the array task_ids.

To send a message from one task to another, a send buffer is created to hold the data. The function pvm_initsend() creates and clears the buffer and returns a buffer identifier.

int bufid = pvm_initsend(int encoding)
If a single buffer is used, pvm_initsend() must be called each time a new message is to be sent, otherwise the new message will be appended to the message already in the send buffer.

The encoding parameter can be either PvmDataDefault or PvmDataRaw. The former option will use XDRgif encoding of message data if the virtual machine configuration is determined to be heterogeneous, else no encoding is done. The latter option does no encoding of the message data.