The scheduler in olsrd runs registered tasks at given intervals. By default the olsrd scheduler polls every 0.1 second. This interval might not be fine-grained enough if running olsr with small emission/hold intervals, therefore it can be set in the configuration file. When using the default emission intervals it should be more than sufficient.
|
As with the socket- and packet-parser, the scheduler is designed in a
modular fashion. One can register and remove scheduled functions at
runtime. Entities that wishes to have some
function, typically a packet generation function, ran at a constant
interval can register this function with the scheduler using this
function, defined in scheduler.h:
int olsr_register_scheduler_event(void (*)(), float, float, olsr_u8_t *);
The first parameter is a pointer to the function to be ran, the second is the interval(in seconds) on which the function is to be ran, the third is the initial time to register as passed since the last call of this function and the fourth is a trigger by which the function can be forced to be called by the scheduler at the next poll.
To register a function that is called on every scheduler poll the following function is used:
int olsr_register_timeout_function(void (*)());
This function is named olsr_register_timeout_function due to the fact that the functions registered to be ran at every scheduler poll is most likely to be functions that times out information in repositories.
At a scheduler poll, all timeouts of all registered functions are
checked and updated. The functions are executed if required. For
functions registered with a trigger, this trigger is checked. If set to
1, the function will be executed regardless of the timer recorded for
it. The timer for that function will then be reset. All
timeout-functions are then ran, and the olsr_process_changes
function is executed to update any changes.
After running all necessary functions the scheduler sleeps for
seconds where processing time
is the time elapsed for the above processing.