kernel: timeout: Optimize setting next alarm
Next timeout was set unconditionally at the end of sys_clock_announce. However, if one of the current expired timeouts was setting a new timeout which is the first to execute then system clock was configured twice. Lets configure system clock only once in the isr at the and of sys_clock_announce. If timeouts are frequent this optimization can reduce CPU load. In many cases setting the new sys_clock timeout is the most time consuming operation in the sys_clock isr handler. As an example, on the target I used setting new sys_clock timeout is taking 6 uS of 9 uS spent in the isr and it takes 16 uS with the redundant call. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
a200dd88d8
commit
aee8dd1d33
|
@ -135,7 +135,7 @@ void z_add_timeout(struct _timeout *to, _timeout_func_t fn,
|
||||||
sys_dlist_append(&timeout_list, &to->node);
|
sys_dlist_append(&timeout_list, &to->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to == first()) {
|
if (to == first() && announce_remaining == 0) {
|
||||||
sys_clock_set_timeout(next_timeout(), false);
|
sys_clock_set_timeout(next_timeout(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue