| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

smtsimu_init

#include "smtsimu.h"
int
smtsimu_init (void)

Synopsis

Initialises the SMT network delay simulation agent. Returns 0 if okay, -1 if there was an error. You do not need to call this function explicitly. To use SMTSIMU, include "smtsimu.h" in your program after "smtlib.h". This redefines the standard socket functions to go through SMTSIMU. Sends all errors to the SMTOPER agent.

Source Code - (smtsimu.c)

{
    AGENT   *agent;                     /*  Handle for our agent             */
    THREAD  *thread;                    /*  Handle to console thread         */
#   include "smtsimu.i"                 /*  Include dialog interpreter       */

    /*                      Method name     Event value      Priority        */
    /*  Shutdown event comes from Kernel                                     */
    method declare (agent, "SHUTDOWN",      shutdown_event,  SMT_PRIORITY_MAX);

    /*  Public methods supported by this agent                               */
    method declare (agent, "TIME_ALARM",    alarm_event,     0);
    method declare (agent, "TIME_ERROR",    error_event,     0);

    /*  Ensure that operator console is running, else start it up            */
    smtoper init ();
    if ((thread = thread lookup (SMT_OPERATOR, "")) != NULL)
        operq = thread-> queue-> qid;
    else
        return (-1);

    /*  Ensure that timer agent is running, else start it up               */
    smttime init ();
    if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
        timeq = thread-> queue-> qid;
    else
        return (-1);

    /*  Create initial thread                                                */
    if ((thread = thread create (AGENT_NAME, "")) != NULL)
        simuq = thread-> queue-> qid;
    else
        return (-1);

    /*  Initialise static variables */
    last_id = 0;

    /*  Signal okay to caller that we initialised okay                       */
    return (0);
}

| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation