Collaboration diagram for Timer services.:
![]() |
If the underlying timer source is aperiodic, we need to reprogram the next shot after each tick at hardware level, and we do not need any periodic source. In such a case, the timer manager only uses a single slot (#0) from the wheel as a plain linked list, which is ordered by increasing timeout values of the running timers.
Depending on the above mode, the timer object stores time values either as count of periodic ticks, or as count of CPU ticks.
The current implementation assumes that the maximum number of outstanding timers in aperiodic mode is low (< 16?). Would this assumption prove false, we would need to go for an AVL of some sort, likely a RB tree. The periodic mode is already based on a timer wheel, so there should not be any problem here, unless your application is some ugly monster from the dark ages...
Files | |
file | timer.c |
Functions | |
void | xntimer_do_tick_aperiodic (void) |
Process a timer tick in aperiodic mode. | |
void | xntimer_do_tick_periodic (void) |
Process a timer tick in periodic mode. | |
void | xntimer_init (xntimer_t *timer, void(*handler)(void *cookie), void *cookie) |
Initialize a timer object. | |
void | xntimer_destroy (xntimer_t *timer) |
Release a timer object. | |
void | xntimer_start (xntimer_t *timer, xnticks_t value, xnticks_t interval) |
Arm a timer. | |
xnticks_t | xntimer_get_date (xntimer_t *timer) |
Return the absolute expiration date. | |
xnticks_t | xntimer_get_timeout (xntimer_t *timer) |
Return the relative expiration date. | |
void | xntimer_freeze (void) |
Freeze all timers. |
|
Release a timer object. Destroys a timer. After it has been destroyed, all resources associated with the timer have been released. The timer is automatically deactivated before deletion if active on entry.
This service can be called from:
Rescheduling: never. |
|
Process a timer tick in aperiodic mode.
For internal use only. This routine informs all active timers that the clock has been updated by processing the outstanding timer list. Elapsed timer actions will be fired. Environments: This service can be called from:
Rescheduling: never.
|
|
Process a timer tick in periodic mode.
For internal use only. This routine informs all active timers that the clock has been updated by processing the timer wheel. Elapsed timer actions will be fired. Environments: This service can be called from:
Rescheduling: never.
|
|
Freeze all timers.
For internal use only. This routine deactivates all active timers atomically. Environments: This service can be called from:
Rescheduling: never.
|
|
Return the absolute expiration date. Return the next expiration date of a timer in absolute clock ticks (see note).
This service can be called from:
Rescheduling: never.
|
|
Return the relative expiration date. Return the next expiration date of a timer in relative clock ticks (see note).
This service can be called from:
Rescheduling: never.
|
|
Initialize a timer object. Creates a timer. When created, a timer is left disarmed; it must be started using xntimer_start() in order to be activated.
Environments: This service can be called from:
Rescheduling: never. |
|
Arm a timer. Activates a timer so that the associated timeout handler will be fired after each expiration time. A timer can be either periodic or single-shot, depending on the reload value passed to this routine. The given timer must have been previously initialized by a call to xntimer_init().
This service can be called from:
Rescheduling: never.
|