DML_process Class

Declared:

#include <DML_process.h>    

Derived From:

none

Description

The DML_process class is a base class, from which both the DML_chid and DML_master classes are derived. It contains basic methods for communicating with other processes, and storing relevant information.

Public Class Members

Public member data:

pid_t pid
int priority  

Public member functions:

DML_process()
DML_process( const char *, const nid_t = 0 )
int fork()
send( const int )
send( void *, const size_t )
pid_t receive( int & )
pid_t receive( void *, size_t )
slay( const int = SIGTERM )
kill( const int = SIGTERM )
void * poll( void *, size_t )
int checkMsgBackup()
operator pid_t()
DML_process & operator << ( const int )
DML_process & operator << ( const char * )
DML_process & operator << ( const char )
DML_process & operator << ( const float )
DML_process & operator << ( const double )
DML_process & operator << ( const long )
DML_process & operator >> (int &)
DML_process & operator >> (char *)
DML_process & operator >> (char &)
DML_process & operator >> (float &)
DML_process & operator >> (double &)
DML_process & operator >> (long &)  

See Also:

DML_child, DML_master

 

Class Member Functions

DML_process::DML_process

Synopsis:

#include <DML_process.h>


DML_process::DML_process()
DML_process::DML_process( cons char *, const nid_t = 0 )

Semantics:

The first form of this constructor simply creates a blank DML_process data structure. This process can later be forked. The second form of this constructor creates a new data structure from an EXISTING process, from the executable name in the first argument, on the node specified by the second argument, using the qnx_spawn function. Note that neither constructor actually creates a new process.

Code Dissection:

The first of these constructors is the more useful of the two. The second is useful for looking up an existing process (which must have registered itself under the qnx name server nameloc), but the first is used for later forking.

Results:

The data structure is created

See Also:

DML_child::DML_child, DML_master::DML_master

 

DML_process::fork

Synopsis:

#include <DML_process.h>


int DML_process::fork()

Semantics:

This function performs an execution fork on the current process, by calling the UNIX basic function fork. See the description for fork.

Code Dissection:

This function is a simple cover for the generic fork() function.

Results:

Returns FORK_MASTER if it's the original process, FORK_CHILD if it's the child process, and FORK_FAIL if an error occurred.

See Also:

fork

 

DML_process::Send

Synopsis:

#include <DML_process.h>

DML_process::Send( const int )
DML_process::Send( const void *, const size_t )

Semantics:

The two forms of the DML_process::Send function are really just covers for the two most common types of QNX message sends: a simple integer, and a one-way message of any size. The first sends an int to the process and discards the return message, if any. The second sends an arbitrary-sized message.

Code Dissection:

These functions are just covers for the QNX messaging Send() function.

Results:

does not return anything. The message Send is attempted. There is no indicator whether or not it succeeded, which is probably a bad idea. It really should return a status int, but it doesn't.

See Also:

Send, DML_process::operator << () , DML_process::receive

 

 

DML_process::receive

Synopsis:

#include <DML_process.h>


pid_t DML_process::receive( int & )
pid_t DML_process::receive( void *, size_t )

Semantics:

The receive() member functions are exactly like the send() member functions: they're simply covers for the generic QNX messaging functions. In addition, these functions automatically generate a Reply to the message, so you don't have to. Note that there is no Reply method for this class... that would be too confusing.

Code Dissection:

Just another cover function.

Results:

Returns the pid that was received from (why is this here? I don't know.) Oh that's right. It returns PROC_DNE (-1) if there was a receive error (which usually means the process doesn't exist).

See Also:

DML_process::send, Receive, DML_process::operator >> ()

 

 

DML_process::slay and DML_process::kill

Synopsis:

#include <DML_process.h>

DML_process::slay( const int = SIGTERM )
DML_process::kill( const int = SIGTERM )

Semantics:

These functions immediately sends a termination (or other) signal to the process.

Code Dissection:

Just a cover for the kill() global function.

Results:

The process in question will receive a signal: usually this will result in process termination, unless the process has installed a signal handler

See Also:

kill, signal

 

DML_process::poll

Synopsis:

#include <DML_process.h>

void * DML_process::poll( void *, size_t )

Semantics:

This is the non-blocking version of receive. It will not block if no message is available. This function should not be used very often: polling is in general very bad practice.

Code Dissection:

This function is just a cover for the Creceive function.

Results:

Returns a pointer to the data (i.e. the input parameter), or NULL if no message is available.

See Also:

Creceive()

 

DML_process::checkMsgBackup

Synopsis:

#include <DML_process.h>


int DML_process::checkMsgBackup()

Semantics:

This function is not yet implemented. I never got around to finishing it, so I ditched all the code and it simply returns the pid, if valid, or PROC_DNE if not. In theory, it checks all current processes to see how many are Send-blocked on the current process, using the qnx_psinfo function. Therefore, it will be extremely slow. Have fun: try to implement it.

Code Dissection:

Not yet implemented.

Results:

returns the process PID or PROC_DNE (-1) if the process is invalid.

See Also:

none

 

DML_process::operator pid_t()

Synopsis:

#include <DML_process.h>


DML_process::operator pid_t()

Semantics:

This conversion operator converts a DML_process object (or any derived class) into a pid_t.

Code Dissection:

Self-explanatory.

Results:

This function returns a copy of the process PID.

See Also:

none

 

DML_process:: operator <<

Synopsis:

#include <DML_process.h>


DML_process & operator << ( const int )
DML_process & operator << ( const char * )
DML_process & operator << ( const char )
DML_process & operator << ( const float )
DML_process & operator << ( const double )
DML_process & operator << ( const long )

Semantics:

These functions are simple covers for the Send function. They can be used to easily send basic information to the process, using QNX messaging. Any return message is discarded.

Code Dissection:

These functions are just inline covers for the Send method. They're listed in the header file, since they're inline.

Results:

These functions return a reference to the DML_process object.

See Also:

DML_process::operator >>, DML_process::send, Send

 

DML_process:: operator >>

Synopsis:

#include <DML_process.h>


DML_process & operator >> (int &)
DML_process & operator >> (char *)
DML_process & operator >> (char &)
DML_process & operator >> (float &)
DML_process & operator >> (double &)
DML_process & operator >> (long &)

Semantics:

These functions are simple covers for the Receive function. They can be used to easily receive basic information to the process, using QNX messaging. An autormatic Reply is generated.

Code Dissection:

These functions are just inline covers for the Receive/Reply method. They're listed in the header file, since they're inline.

Results:

These functions return a reference to the DML_process object.

See Also:

DML_process::operator <<, DML_process::receive, Receive, Reply