GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > MSG / V3-0-2

Constituent: msg2src     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

MSG_control.c File Reference

Routines to handle all control aspects of MSG system control. More...

#include <stdlib.h>
#include <string.h>
#include "PBS/MBA.h"
#include "PBS/TASK.h"
#include "PBS/WCT.h"
#include "MDB/MDB_pubdefs.h"
#include "MSG/MSG_msgs.h"
#include "MSG_health.h"
#include "MSG_prvdefs.h"

Include dependency graph for MSG_control.c:

Include dependency graph

Functions

unsigned int countsSince (MSG_Counts *cnt, unsigned int sel, unsigned int rst)
 Worker bee for MSG_countsSinceStart() and MSG_countsSinceReset().

unsigned int MSG_countsSinceReset (MSG_Counts *cnt, unsigned int rst)
 Return instrumentation counts since last reset.

unsigned int MSG_countsSinceStart (MSG_Counts *cnt)
 Return instrumentation counts since message task started.

unsigned int MSG_getCtlThread ()
 Return the threading model.

unsigned int MSG_initialize (const MSG_InitPrm *prm)
 Take message system from state MSG_S_UNINITIALIZED to state MSG_S_INITIALIZED.

unsigned int MSG_shutdown ()
 Take message system from state MSG_S_INITIALIZED to state MSG_S_UNINITIALIZED.

unsigned int MSG_startTask (const TASK_attr *attr)
 Take message system from state MSG_S_INITIALIZED to state MSG_S_STARTED.

unsigned int MSG_stopTask ()
 Take message system from state MSG_S_STARTED to state MSG_S_INITIALIZED.


Variables

const unsigned int threaded = 1
 Carry knowledge of the threading model into the run time environment.

MSG_Control * MSG_mcb
 Pointer to message control block structure.

MSG_AltMessage MSG_alt [MSG_L_ALTERNATE]
 Translation table for the eight "special" messages.


Detailed Description

Routines to handle all control aspects of MSG system control.

CVS $Id: MSG_control.c,v 1.12 2005/09/22 01:45:07 apw Exp $
Author:
A.P.Waite
MSG_control.c contains all the routines needed to initialize, start up, stop and shut down the MSG system.

Function Documentation

unsigned int countsSince MSG_Counts *  cnt,
unsigned int  sel,
unsigned int  rst
[static]
 

Worker bee for MSG_countsSinceStart() and MSG_countsSinceReset().

Parameters:
cnt MSG_Counts block into which to put the results
sel Selector (0/1 => since start/since reset)
rst Reset flag (0/1 => no reset/reset)
Return values:
MSG_BADSTATE 
MSG_SUCCESS countsSince() is the worker bee for the MSG_countsSinceStart() and MSG_countsSinceReset() routines.

unsigned int MSG_countsSinceReset MSG_Counts *  cnt,
unsigned int  rst
 

Return instrumentation counts since last reset.

Parameters:
cnt MSG_Counts block into which to put the results
rst Reset flag (0 => don't reset, otherwise reset)
Return values:
MSG_BADSTATE Message system not initialized
MSG_SUCCESS Success
MSG_countsSinceReset() returns an instrumentation block giving (bread and butter case), message counts and high and low water marks for packet usage since the last reset. This makes sense while the message task is running. The following table gives details of what's returned when the message task is not running.

MSG state MSG task has run at least once Return code Contents of instrumentation block
MSG_S_UNINITIALIZED n/a MSG_BADSTATE All zero
MSG_S_INITIALIZED no MSG_SUCCESS Fake statistics for a zero length run of the MSG task
MSG_S_INITIALIZED yes MSG_SUCCESS Statistics from most recent reset to time MSG task stopped

Here is the call graph for this function:

unsigned int MSG_countsSinceStart MSG_Counts *  cnt  ) 
 

Return instrumentation counts since message task started.

Parameters:
cnt MSG_Counts block into which to put the results
Return values:
MSG_BADSTATE Message system not initialized
MSG_SUCCESS Success
MSG_countsSinceStart() returns an instrumentation block giving (bread and butter case), message counts and high and low water marks for packet usage since the message task was started. This makes sense while the message task is running. The following table gives details of what's returned when the message task is not running.

MSG state MSG task has run at least once Return code Contents of instrumentation block
MSG_S_UNINITIALIZED n/a MSG_BADSTATE All zero
MSG_S_INITIALIZED no MSG_SUCCESS Fake statistics for a zero length run of the MSG task
MSG_S_INITIALIZED yes MSG_SUCCESS Statistics for the most recent run of the MSG task

Here is the call graph for this function:

unsigned int MSG_getCtlThread  ) 
 

Return the threading model.

Return values:
0 Single-threaded
1 Multi-threaded
The major use of MSG_getCtlThread() is testing.

unsigned int MSG_initialize const MSG_InitPrm *  prm  ) 
 

Take message system from state MSG_S_UNINITIALIZED to state MSG_S_INITIALIZED.

Parameters:
prm (in) Parameter block contining initialization information (note 1)
Note:
  1. If prm is NULL, MSG_initialize() will provide a default (currently 32 message packets of 256 bytes each). If prm is not NULL, the caller need not make the storage for the MSG_InitPrm structure persistent.
Return values:
MSG_ALOCFAIL Fixed packet allocator (FPA) buffer allocation failed
MSG_BADSTATE Cannot initialize in the current MSG state
MSG_FINDFAIL Cannot look up up alternate messages in database
MSG_FPAIFAIL Fixed packet allocator (FPA) initialization failed
MSG_MUALOCFL Cannot allocate a mutex
MSG_PKT2FEW Packet count parameter too small
MSG_PKT2SMAL Packet length parameter too small
MSG_SUCCESS Success
MSG_initialize() initializes the message system according to the parameters provided in the parameterization block.

Here is the call graph for this function:

unsigned int MSG_shutdown  ) 
 

Take message system from state MSG_S_INITIALIZED to state MSG_S_UNINITIALIZED.

Return values:
MSG_BADSTATE Cannot shut down in the current MSG state
MSG_SUCCESS Success
MSG_shutdown() detaches all attached output processors and frees all resources associated with the message system.

unsigned int MSG_startTask const TASK_attr *  attr  ) 
 

Take message system from state MSG_S_INITIALIZED to state MSG_S_STARTED.

Parameters:
attr (in) Task attributes block containing task start-up information (note 1)
Note:
  1. If attr is NULL, MSG_startTask() will provide a default. If attr is not NULL, the caller need not make the storage for the TASK_attr structure persistent.
Return values:
MSG_BADSTATE Cannot start in the current MSG state
MSG_FORKFAIL FORK initialization failed
MSG_FPAGFAIL Fixed packet allocator get failed during task start
MSG_SUCCESS Success
In multi-threaded mode, MSG_startTask() forks a task (with the attributes defined in the task attributes block passed into this routine) to receive and process messages.

In single-threaded mode, MSG_startTask() does not fork a task, and all message processing is done inline with the MSG_report() call. The task attributes block is ignored.

In both modes (and before the task fork in multi-threaded mode), MSG_startTask() calls each of the output processing routines in turn with a flag to indicate an inialization call.

Here is the call graph for this function:

unsigned int MSG_stopTask  ) 
 

Take message system from state MSG_S_STARTED to state MSG_S_INITIALIZED.

Return values:
MSG_BADSTATE Cannot stop in the current MSG state
MSG_SUCCESS Success
In multi-threaded mode, MSG_stopTask() runs down the task forked in MSG_startTask() and releases the resources associated with it.

In single-threaded mode, there is no forked task to run down.

In both modes (and after the forked task has run down in multi-threaded mode), MSG_stopTask() calls each of the output processing routines in turn with a flag to indicate a cleanup call.


Variable Documentation

MSG_AltMessage MSG_alt[MSG_L_ALTERNATE]
 

Initial value:

        { { MSG_UNKNOWNS, NULL, NULL },
          { MSG_UNKNOWNW, NULL, NULL },
          { MSG_UNKNOWNI, NULL, NULL },
          { MSG_UNKNOWNE, NULL, NULL },
          { MSG_UNIXGOOD, NULL, NULL },
          { MSG_UNIXEROR, NULL, NULL },
          { MSG_GAPBEGIN, NULL, NULL },
          { MSG_GAPEND,   NULL, NULL } }
Translation table for the eight "special" messages.

Small database to make the substitution of alternative messages more efficient. The NULLs are replaced during the initialization phase (once only).

MSG_Control * MSG_mcb
 

Pointer to message control block structure.

Pointer to the control block for the message system.

static const unsigned int threaded = 1 [static]
 

Carry knowledge of the threading model into the run time environment.

Used mainly for testing purposes.


Generated on Thu Sep 22 08:08:47 2005 by doxygen 1.3.3