Desc. & Idea | Warnings | Methods | Atributes |
This object is designed for message buffering, adding message handling features (including retrieving messages with specified attributes) other process IDs management etc.
Changes since the last version :
Public:
============= Constructors and Destructors ============
PVM_CODEC (int procType);
~PVM_CODEC ();
============= General functions =============
int startProcess (char *fileName, char **argv,
int taskAmount);
int startProcess (char *fileName, char **argv, char *hostName,
int taskAmount, int *procPids);
int getProcessType ();
============= Coating functions =============
BOOL getPids (int **pids, int **procTypes, int *pidAmount);
BOOL getParentPids (int **pids, int *pidAmount);
BOOL getChildPids (int **pids, int *pidAmount);
BOOL getApplicationPids (int **pids, int *pidAmount);
int getMaxBufByPid (int procPid);
void setMaxBufByPid (int procPid, int maxAmount);
void setMaxBufByType (int procType, int maxAmount);
void setMaxBufToAll (int maxAmount);
int getRecMsgAmount (int priority);
============= Receiving =============
BOOL retrieveMsgs ();
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);
BOOL getNextRecMsg (int priority, BYTE **msg);
BOOL peekNextRecMsg (int priority, BYTE **msg);
void wasteNextRecMsg (int priority);
void wasteRecMsgs (int priority);
void wasteAllMsgs ();
void* getMsgDataPtr (void *msg);
MSG_COMMON* getMsgInfoPtr (void *msg);
int getMsgTag (void *msg);
int getMsgPriority (void *msg);
int getMsgSenderType (void *msg);
int getMsgSpecTag (void *msg);
int getMsgLen (void *msg);
int getMsgSenderPid (void *msg);
int getMsgContentType (void *msg);
int getMsgDataAmount (void *msg);
BOOL isRecMsg (int priority);
============= 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);
void flushPid (int pid);
void flushAll ();
Protected:
int getPidIndex (int pid);
Private:
void checkMyMsgs ();
BOOL getParentPids (int **pids, int *pidAmount);
See function above. Each of these 3 functions return pids of registered tasks of
specific type.
BOOL getChildPids (int **pids, int *pidAmount);
BOOL getApplicationPids (int **pids, int *pidAmount);
Arguments:
pids ........ array of process IDs (is allocated here)
pidAmount ... amount of processes
Returns:
TRUE if there are any processes registered
void setMaxBufByPid (int procPid, int maxAmount);
These functions set the maximum amount of messages allowed to buffer for specific
set of tasks. Either to one task, or to all tasks of specified type, or to all tasks.
void setMaxBufByType (int procType, int maxAmount);
void setMaxBufToAll (int maxAmount);
Arguments:
procPid......................task pid this relies to
procType.....................type of pids this relies to
maxAmount....................the new amount
Returns:
void
BOOL getSpecificMsg (int senderPid, int senderType, int priorityLow,
int priorityHigh, int msgTag, int msgSpecTag, BYTE **msg);
These functions do exactly the same as their PVM_COVER equivalents.
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);
Arguments:
senderPid ........... process ID of the sender
senderType .............. type of the sending process (see above)
priorityLow ............. lowest priority of the message
priorityHigh ............. highest priority of the message
msgTag .................. message tag
msgSpecTag .............. specific message tag
msg ..................... a place to put the message to (is allocated here)
Returns:
TRUE if the message was successfully retrieved. FALSE if either there is insufficient
memory or there is no message in the buffer
BOOL getNextRecMsg (int priority, BYTE **msg);
Both the above functions retrieve the first message from appropriate receive buffer
(specified by "priority"). The first function removes the message from the buffer, the
second doesn't.
BOOL peekNextRecMsg (int priority, BYTE **msg);
Arguments:
priority................specified the receive buffer to get message from (defined
in messages.h)
msg ........ address of pointer to the retrieved message (is allocated here)
Returns:
TRUE if the appropriate buffer contains any message.
void wasteNextRecMsg (int priority);
Each of the above functions removes a message or messages from some buffers.
"wasteAllMsgs" removes all messages from all buffers.
void wasteRecMsgs (int priority);
void wasteAllMsgs ();
Arguments:
priority................specified the receive buffer to retrieve from (defined
in messages.h)
Returns:
void
void* getMsgDataPtr (void *msg);
Every message consists of its message head (MSG_COMMON)
and message data. This function only returns the pointer to the data part of
the message.
MSG_COMMON* getMsgInfoPtr (void *msg);
This function in fact only converts the specified pointer to pointer to message header
struct (MSG_COMMON)
int getMsgTag (void *msg);
Any of these functions return some information retrieved from the message
header (MSG_COMMON)
int getMsgPriority (void *msg);
int getMsgSenderType (void *msg);
int getMsgSpecTag (void *msg);
int getMsgLen (void *msg);
int getMsgSenderPid (void *msg);
int getMsgContentType (void *msg);
int getMsgDataAmount (void *msg);
Public:
BYTE * recBuffers[PRIORITY_PAMOUNT];
int recBufLens[PRIORITY_PAMOUNT], recMsgAmounts[PRIORITY_PAMOUNT];
int processType;
int *procPids, *procTypes, procAmount;
Protected:
Private:
BYTE **sendBuffers;
int *sendBufLens, *sendMsgAmounts, *maxBufMsgAmounts;
BYTE *recBuffers[PRIORITY_PAMOUNT];
Buffers for receiving messages. Every layer of our system has a separate buffer
(which message where is told by the "priority" attribute in
MSG_COMMON).
int recBufLens[PRIORITY_PAMOUNT], recMsgAmounts[PRIORITY_PAMOUNT];
Attributes of the receive buffers
int *procPids, *procTypes, procAmount;
Arrays of process IDs and process types of all registered processes and the amount of
registered processes. See getPids for more information.