This class covers PVM (Parallel Virtual Machine). This means that it contains all functions needed for spawning tasks, communication, retrieving messages, getting information etc. These functions "cover" the using of PVM, so non of the successors would have to call any PVM routine directly.
In the current version, PVM_COVER expects the PVM daemon to be running. So first start pvm console ("pvm" ENTER) then spawn the parent task (e.g. "pvm -> projekt/pvm/testparent" ENTER; the part "->" specifies that standard output is redirected to the console).
Important changes since the last version :
Important structures used in PVM_COVER :
Outside PVM_COVER:
typedef struct MSG_COMMONtag
{
int msgTag;
int priority;
int senderType;
int specMsgTag;
int msgLen;
int senderPid;
int contentType;
int amount;
} MSG_COMMON;
typedef MSG_COMMON * LPMSG_COMMON;
typedef struct PVMHOSTINFOtag
{
int id;
char *name, *arch;
int speed;
} PVMHOSTINFO;
typedef PVMHOSTINFO *LPPVMHOSTINFO;
typedef struct PVMTASKINFOtag
{
int procID, parentID, hostID, flag;
char *fileName;
} PVMTASKINFO;
typedef PVMTASKINFO * LPPVMTASKINFO;
Methods[Back]
int startDaemon (char **hostNames, int hostAmount);
void sprintError (int pvmError, char *string, int maxLen);
int haltDaemon ();
int exitPvm ();
Public:
Constructors and Destructors
PVM_COVER ();
~PVM_COVER ();
General
void deleteHostInfo (int hostAmount,PVMHOSTINFO *hostInfos);
void deleteTaskInfo (int taskAmount, PVMTASKINFO *taskInfos);
Coating
int getMsgAmount ();
int getMsgBufLen ();
BOOL isMsg ();
Coating PVM
int getMyPid ();
int getParentPid ();
int killProc (int procPid);
int startProcess (char *fileName, char **argv, int taskAmount);
int startProcess (char *fileName,
char **argv, char *hostName, int taskAmount, int *procPids);
int getHostInfo (int *hostAmount, int *archAmount, PVMHOSTINFO **hostInfos);
BOOL isHostAlive (char *hostName);
int getTaskInfo (int *taskAmount, PVMTASKINFO **taskInfos);
BOOL isTaskAlive (int procPid);
Receiving
void unpackMsg (int bufID, void **msg, int *msgTag, int *msgLen,
int *senderProc, int *dataLen);
void wasteMsgs ();
int pvmRetrieve ();
int waitForMsg (int senderPid, int msgTag, int timeOut);
BOOL getSpecificMsg (int senderPid, int senderType,
int priorityLow, int priorityHigh, int msgTag, int msgSpecTag, BYTE **msg);
BOOL peekSpecificMsg (int senderPid, int senderType,
int priorityLow, int priorityHigh, int msgTag, int msgSpecTag, BYTE **msg);
int getNextMsgLen ();
BOOL getNextMsg (char **msg);
============= Sending =============
BOOL sendTypes (int destProc, int senderType, int priority, int msgTag,
int specMsgTag, BYTE type, void *types, int typeAmount);
BOOL multicastTypes (int *destProc, int destProcAmount, int senderType, int priority,
int msgTag, int specMsgTag, BYTE type, void *types, int typeAmount);
BOOL sendBytes (int destProc, int senderType, int priority, int msgTag,
int specMsgTag, BYTE *lpBytes, int byteAmount);
BOOL multicastBytes (int *destProc, int destProcAmount, int senderType, int priority,
int msgTag, int specMsgTag, BYTE *lpBytes, int byteAmount);
BOOL sendTypeMap (int destProc, int senderType, int priority, int msgTag,
int specMsgTag, void *lpMap, int mapLen);
BOOL multicastTypeMap (int *destProc, int destProcAmount, int senderType,
int priority, int msgTag, int specMsgTag, void *lpMap, int mapLen);
Protected:
BOOL getMsgFromBuffer (BYTE **buffer, int *msgAmount,
int *bufLen, BYTE **msg);
BOOL addMsgToBuffer (BYTE **buffer, int *msgAmount,
int *bufLen, BYTE *msg);
BOOL peekMsgFromBuffer (BYTE *buffer, int msgAmount,
int bufLen, BYTE **msg);
void* findSpecMsgInBuffer (BYTE *buffer, int msgAmount,
int bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag);
int countSpecMsgInBuffer (BYTE *buffer, int msgAmount,
int bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag);
BOOL peekSpecMsgFromBuffer (BYTE *buffer, int msgAmount,
int bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag, BYTE **msg);
BOOL getSpecMsgFromBuffer (BYTE **buffer, int *msgAmount,
int *bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag, BYTE **msg);
Private:
BOOL sending (int *destProc, int destProcAmount, int senderType, int priority, int msgTag,
int specMsgTag, BYTE type, void *types, int typeAmount);
BOOL sendingMaps (int *destProc, int destProcAmount, int senderType, int priority, int msgTag,
int specMsgTag, void *lpMap, int mapLen);
PVM_COVER ();
Only initialization of internal atributes.
Arguments:
none
Returns:
~PVM_COVER ();
Freeing allocated space.
Arguments:
none
Returns:
void deleteHostInfo (int hostAmount, PVMHOSTINFO *hostInfos);
Deletes an array of PVMHOSTINFO (tppvm.h) structs. This function is really not neccessary
but might be useful.
Arguments:
hostAmount ......... amount of hosts (amount of structs in the array)
hostInfos .......... pointer to an array of PVMHOSTINFO structs
Returns:
void
void deleteTaskInfo (int taskAmount, PVMTASKINFO *taskInfos);
Similar as deleteHostInfo but deletes an array of PVMTASKINFO structs
Arguments:
taskAmount ......... amount of tasks (amount of structs in the array)
taskInfos .......... pointer to an array of PVMTASKINFO structs
BOOL isMsg ();
Tests if there is a currently retrieved message. This function usually follows after
a call to pvmRetrieve ();
int startProcess (char *fileName, char **argv,
int taskAmount);
Implemented as a call to the other startProcess call.
int getHostInfo (int *hostAmount, int *archAmount,
PVMHOSTINFO **hostInfos);
This function retrieves from PVM some configuration info. Most of it is stored in
an array of structs (is allocated in here - for deallocation use "deleteHostInfo").
Arguments:
hostAmount ........... number of hosts in the PVM configuration
archAmount ........... number of different architectures
hostInfos ............ array of PVMHOSTINFO structs
("hostAmount" items)
is allocated inside the routine.
int getTaskInfo (int *taskAmount, PVMTASKINFO **taskInfos);
Similar to the function above but retrieves information about tasks currently running
under PVM. It only returns information about process that were spawned by the same user
(e.g. if I am jtup4479, I do not get info about tasks spawned by msub4459 even if they
are running on the same machine).
Arguments:
taskAmount ........... number of processes currently running under PVM.
taskInfos ............ array of PVMTASKINFO structs.
void unpackMsg (int bufID, void **msg, int *msgTag, int *msgLen,
int *senderProc, int *dataLen);
This function unpacks data from PVM buffer into the PVM_COVER messages buffer. It respects
the data type information included in every message to guarantee architecture independency.
For more information look for message sending description in the "Docs" section.
Arguments:
bufID ................. PVM buffer ID
msg ................... pointer to MSG_COMMON struct (this struct
is included in every message)
msgLen ................ length of the message
msgData ............... message data
dataLen ............... length of message data (usually == msgLen - sizeof(MSG_COMMON))
msgTag ................ message tag (info supplied by PVM; always == msg->msgTag)
senderProc ............ process ID of the sender (--- || -- ; always == msg->senderPid)
BOOL getSpecificMsg (int senderPid, int senderType, int priorityLow,
int priorityHigh, int msgTag, int msgSpecTag, BYTE **msg);
This function retrieves a message of specified attributes from the PVM_COVER message buffer
(this function would typically follow a call to pvmRetrieve).
For description of the attributes look at the MSG_COMMON structure.
You can specify "-1" instead of any of the message attributes. (e.g.
getSpecificMsg (-1, SENDER_PARENT, -1, -1, MT_PID, 0, msg);)
BOOL peekSpecificMsg (int senderPid, int senderType, int priorityLow,
int priorityHigh, int msgTag, int msgSpecTag, BYTE **msg);
This function reads a message of specified attributes from the PVM_COVER message buffer
(this function would typically follow a call to pvmRetrieve). The message is not erased from the
buffer. For description of the attributes look at the
MSG_COMMON structure. You can specify "-1" instead of any of the
message attributes. (e.g. getSpecificMsg (-1, SENDER_PARENT, -1, -1, MT_PID, 0, msg);)
BOOL sendBytes (int destProc, int senderType, int priority, int msgTag,
int specMsgTag, BYTE *lpBytes, int byteAmount);
Implemented as a call to the function sendTypes but with a
specific type (TYPE_BYTE).
void* findSpecMsgInBuffer (BYTE *buffer, int msgAmount,
int bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag);
This function looks for a message of specified attributes in the specified buffer.
For description of the attributes look at the MSG_COMMON structure.
You can specify "-1" instead of any of the message attributes. (e.g.
point = findSpecMsgInBuffer (allMsgBuf, msgAmount, bufLen, -1, SENDER_PARENT,
-1, -1, MT_PID, 0);)
int countSpecMsgInBuffer (BYTE *buffer, int msgAmount, int bufLen,
int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag);
This function looks for all messages of specified attributes in the specified buffer.
For description of the attributes look at the MSG_COMMON structure.
You can specify "-1" instead of any of the message attributes. (e.g.
point = findSpecMsgInBuffer (allMsgBuf, msgAmount, bufLen, -1, SENDER_PARENT,
-1, -1, MT_PID, 0);)
BOOL peekSpecMsgFromBuffer (BYTE *buffer, int msgAmount,
int bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag, BYTE **msg);
This function retrieves a message of specified attributes from the specified buffer, but
does not remove it from the buffer and modifies neither the "msgAmount" nor the "bufLen".
For description of the attributes look at the MSG_COMMON structure.
You can specify "-1" instead of any of the message attributes. (e.g.
peekSpecMsgFromBuffer (allMsgBuf, msgAmount, bufLen, -1, SENDER_PARENT,
-1, -1, MT_PID, 0, &msg);)
BOOL getSpecMsgFromBuffer (BYTE **buffer, int *msgAmount,
int *bufLen, int senderPid, int senderType, int priorityLow, int priorityHigh,
int msgTag, int msgSpecTag, BYTE **msg);
This function retrieves a message of specified attributes from the specified buffer and
reallocates the buffer and modifies the "msgAmount" and "bufLen".
For description of the attributes look at the MSG_COMMON structure.
You can specify "-1" instead of any of the message attributes. (e.g.
getSpecMsgFromBuffer (&allMsgBuf, &msgAmount, &bufLen, -1, SENDER_PARENT,
-1, -1, MT_PID, 0, &msg);)
Public:
BOOL terminate;
BOOL pause;
Protected:
Private:
BYTE * allMsgBuf;
int allMsgBufLen;
int allMsgAmount;
int allMsgBufLen;
The overall length of messages currently present in allMsgBuf
int allMsgAmount;
The number of messages currently present in allMsgBuf.