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

 

smttime_init

#include "smtdefn.h"
int
smttime_init (void)

Synopsis

Initialises the SMT timer agent. Returns 0 if initialised okay, -1 if there was an error. The timer agent provides timing events after a certain delay, at a specific time, or at a specific frequency. When you initialise the timer agent it creates an unnamed thread automatically. Send events to this thread. The timer accuracy is 1/100th of a second, depending on the system capacity and speed. Supports these public methods:
ALARM Send an alarm after some delay (use SMT_TIME_ALARM).
WAKEUP Send an alarm at some time (use SMT_TIME_ALARM).
CLOCK Send an alarm at some frequency (use SMT_TIME_CLOCK).
FLUSH Cancel all timing events for a client thread.
Sends errors to the SMTOPER agent; see doc for reply events.

Source Code - (smttime.c)

{
    AGENT   *agent;                     /*  Handle for our agent             */
#   include "smttime.i"                 /*  Include dialog interpreter       */

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

    /*  Timer event sent by kernel to the timer agent (this program)         */
    method declare (agent, "TIMER",          timer_event,    0);

    /*  Private event, used to loop if no system timers are available        */
    method declare (agent, "_TIMER",         timer_event,    SMT_PRIORITY_LOW);

    /*  Public methods supported by this agent                               */
    method declare (agent, "ALARM",          alarm_event,    0);
    method declare (agent, "WAKEUP",         wakeup_event,   0);
    method declare (agent, "CLOCK",          clock_event,    0);
    method declare (agent, "FLUSH",          flush_event,    0);

    /*  Create initial, unnamed thread                                       */
    thread create (AGENT_NAME, "");

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

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