DML_master Class

Declared:

#include <DML_child.h>    

Derived From:

DML_process

Description

The DML_master class is a simple convenience class for coordinating with the DML_child class. If one process spawns another using the DML_child class, this DML_master class can be used on the spawned end to communicate easily with the parent process, using the sendInfoMsg() and other methods. Remember: if a process is the child of another process, it should create a DML_master class instance to refer to the parent process. The parent process creates a DML_child class instance to refer to the child.

If a process is an "intermediate master", where it is spawned by a process under the programmer's control, and spawns processes under its control, you'd like to have easy access to both the process's parent and child processes. To do this, BE SURE to declare the DML_master class AFTER having declared at least one child process. Otherwise, the intermediate master will not handle the termination of its child processes properly. Though this is not a vital concern, it would produce erroneous results when using the printChildren() command.

Public Class Members

Public member data:

pid_t proxy
int verbosity  

Public member functions:

DML_master()
sendInfoMsg()  

See Also:

DML_child, DML_process

 

Class Member Functions

 

DML_master::DML_master

Synopsis:

#include <DML_child.h>


DML_master::DML_master()

Semantics:

This function creates the DML_master data structure. Note that since the master process already exists, this function doesn't spawn any new processes. Instead, it just grabs some info about the process which spawned the current process.

Code Dissection:

This is a very simple function. It only gets information about the parent process, using getppid(). Note that the priority data member is the CURRENT process priority, not the master's process priority. Why I did it this way I'm not sure, but it has to do with the sendInfoMsg() function. I'd re-write it if there was a real reason.

Results:

The DML_master object is created.

See Also:

DML_child::DML_child

 

DML_master::sendInfoMsg

Synopsis:

#include <DML_child.h>


DML_master::sendInfoMsg()

Semantics:

This function is a companion to the DML_child::sendInfoMsg() function. This function should be called both by the parent process and the child process just after creation: it will synchronize the processes at precise points in the code. It is primarily a program flow control tool.

Code Dissection:

This function gathers information about the current process, Receives a message, Replies, and stores some info about the parent process.

Results:

The function blocks the process until the master process calls DML_child::sendInfoMsg on this process.

See Also:

DML_child::sendInfoMsg()