DIM
Distributed Information Management
System


4.5 Timer Library (DTQ)

Detailed description of the routines contained in the Timer Utility Library : 

dtq_start_timer

Start a TimeOut request

Format

void dtq_start_timer (time, user_routine, tag)

Arguments

int time;

The time in seconds after which the user_routine should be called.

void *user_routine;

The address of a routine to be executed when the timer expires.

long tag;

A parameter to be sent to the user_routine in order to identify the Timeout request. Tag is also used as Request Identifier in order to stop the timer.

Description

This routine starts a timer. When the timer expires the user_routine will be called.

dtq_stop_timer

Stop (cancel) a TimeOut request

Format

void dtq_stop_timer (tag)

Arguments

long tag;

The parameter given to dtq_start_timer.

Description

This routine stops the timer. The user_routine will no longer be called.

dtq_sleep

Sleep for a number of seconds

Format

void dtq_sleep(time)

Arguments

int time;

The time in seconds the process should be suspended for.

Description

This routine suspends the process for the given number of seconds. In Unix the sleep function exits when the process receives a signal, since DIM uses signals, processes using the UNIX call directly will exit several times and it would be difficult to compute the actual time slept. dtq_sleep can be used instead it only exits when the sleep time elapses.

user_routine

Routine written by the user, called when the timer started by dtq_start_timer expires.

Format

void user_routine (tag)

Arguments

long tag;

The parameter that identifies the request. The tag given to dtq_start_timer.

Description

This routine is called when a timer started by dtq_start_timer expires.