TNeo
v1.08
|
The kernel needs to calculate timeouts.
There are two schemes available: static tick and dynamic 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:
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:
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:
tn_tick_int_processing()
after N
ticks;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()
)