timers.h File Reference

Include functions for initialization, starting and destroing timers. More...

Go to the source code of this file.

Data Structures

struct  _timer_list
struct  timer

Defines

#define MSIM_FREQUENCY_USEC   1
#define MSIM_FREQUENCY   (MSIM_FREQUENCY_USEC*1000000)

Typedefs

typedef _timer_list timer_list
typedef timer_list timer_list_t
typedef timer timer_t

Functions

int timer_init (timer_t *tmr, const unsigned int usec, void(*handler)(timer_t *, void *), void *data)
void timer_start (timer_t *tmr)
 Function activate timer.
void timer_destroy (timer_t *tmr)
 Function deactivate timer.
int timer_pending (timer_t *tmr)
 Function return that the timer is pending.
void timer_check ()
 Function is searching for timers with runned out delay.
unsigned get_sysutime ()
 Function returns count of microseconds from cpu start.
int init_timers ()
 Function initialized list of timers.
void timer_debug (void)
 Debug walk trough.


Detailed Description

Include functions for initialization, starting and destroing timers.

Timers are system structures, that allows threads raise asynchronous event. There is no need to allocate memory for this event, like threads must when creating new thread. The timer handling function is called after delay, that thread can specified. Timers handling functions runs in context of thread, that was interuppted. Timers are storage in list, where timer structure has pointer to next timer.


Define Documentation

#define MSIM_FREQUENCY   (MSIM_FREQUENCY_USEC*1000000)

Count of procesor ticks per a second

#define MSIM_FREQUENCY_USEC   1

Count of procesor ticks per a microsecond


Typedef Documentation

typedef struct _timer_list timer_list

usual notation with .._t

typedef struct timer_list timer_list_t

usual notation with .._t

typedef struct timer timer_t

usual notation with .._t


Function Documentation

unsigned get_sysutime (  ) 

Function returns count of microseconds from cpu start.

Returns:
Number of microseconds from cpu start

int init_timers (  ) 

Function initialized list of timers.

Returns:
EOK on success or ENOMEM on system memory lack

void timer_check (  ) 

Function is searching for timers with runned out delay.

Function walk trough the list of timers. If the delay is runned out (count of cpu cycles is less than stop_cycle) the timer is destroyed and handle function is called with parametres, that point to timer and inserted data.

void timer_debug ( void   ) 

Debug walk trough.

Walk trough list of timers and print timers pointer and next pointer.

void timer_destroy ( struct timer tmr  ) 

Function deactivate timer.

Parameters:
tmr - pointer to timer structure
Function walk trough list of timers and find out the timer in parametr. This timer is stopped, stop cycle is set to 0, and is remove from list of timers.

int timer_pending ( struct timer tmr  ) 

Function return that the timer is pending.

Parameters:
tmr - pointer to timer structure
Returns:
- 1 if the timer is pending, otherwise 0
Function return 1 if the timer is pending, it means that stop cycle is great than actual count of cpu cycles from cpu start. Otherwise function return 0.

void timer_start ( struct timer tmr  ) 

Function activate timer.

Parameters:
tmr - pointer to timer structure
Function activate timer and insert it to the tail of list of active timers. Activation mean that the stop_cycle value is set to count of cpu cycles + timer microseconds multiply by cpu cycles per microseconds. If the timer in argument is pending, than it is restarted - it stay in list of active timers and stop_cycle value is again computed to the new value


Generated on Wed Nov 15 17:25:44 2006 for Kalisto by  doxygen 1.4.7