TNeo  v1.08
Time ticks

Table of Contents

The kernel needs to calculate timeouts.

There are two schemes available: static tick and dynamic tick.

Static tick

Static tick is the easiest way to implement timeouts: there should be just some kind of hardware timer that generates interrupts periodically. Throughout this text, this timer is referred to as system timer. The period of this timer is determined by user (typically 1 ms, but user is free to set different value). In the ISR for this timer, it is only necessary to call the tn_tick_int_processing() function:

//-- example for PIC32, hardware timer 5 interrupt:
tn_p32_soft_isr(_TIMER_5_VECTOR)
{
INTClearFlag(INT_T5);
}

But for some applications that spend a lot of time doing nothing this could be far from perfect: instead of being constantly in the power-saving mode while there's nothing to do, the CPU needs to wake up regularly. So, dynamic tick scheme was implemented:

Dynamic tick

The general idea is that there should be no useless calls to tn_tick_int_processing(). If the kernel needs to wake up after 100 system ticks, then, tn_tick_int_processing() should be called exactly after 100 periods of system tick (but external asynchronous events still can happen and re-schedule that, of course).

To this end, the kernel should be able to communicate with the application:

To use dynamic tick, turn the option TN_DYNAMIC_TICK to 1.

Then, a couple of callback prototypes becomes available:

And you must provide these callbacks to tn_callback_dyn_tick_set() before starting the system (i.e. before calling tn_sys_start())

Attention
In dynamic tick mode, round-robin is not yet supported.