#include "timers.h"
#include "sys.h"
#include "errnums.h"
#include "debug.h"
#include "io.h"
#include "malloc.h"
Functions | |
int | timer_init (struct timer *tmr, const unsigned int usec, void(*handler)(struct timer *, void *), void *data) |
Function inicialized structure of timer. | |
void | timer_start (struct timer *tmr) |
Function activate timer. | |
void | timer_destroy (struct timer *tmr) |
Function deactivate timer. | |
void | timer_debug (void) |
Debug walk trough. | |
int | timer_pending (struct timer *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. | |
Variables | |
timer_list * | timer_ll |
A global list of timers in the system. |
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.
unsigned get_sysutime | ( | ) |
Function returns count of microseconds from cpu start.
int init_timers | ( | ) |
Function initialized list of timers.
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.
tmr | - pointer to timer structure |
int timer_init | ( | struct timer * | tmr, | |
const unsigned int | usec, | |||
void(*)(struct timer *, void *) | handler, | |||
void * | data | |||
) |
Function inicialized structure of timer.
tmr | - pointer to timer structure | |
usec | - count of microseconds, that determine delay of timer | |
handler | - pointer to function, that is called after delay is runned out | |
data | - pointer to data, that are passed to handler |
int timer_pending | ( | struct timer * | tmr | ) |
Function return that the timer is pending.
tmr | - pointer to timer structure |
void timer_start | ( | struct timer * | tmr | ) |
Function activate timer.
tmr | - pointer to timer structure |