Skip to content

Commit

Permalink
kernel/timeout: Fix off-by-one in absolute timeouts
Browse files Browse the repository at this point in the history
The computation was using the already-adjusted input value that
assumed relative timeouts and not the actual argument the user passed.
Absolute timeouts were consistently waking up one tick early.

Fixes zephyrproject-rtos#32499

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
Andy Ross committed Feb 19, 2021
1 parent 71d7f3f commit c4ad8e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void z_add_timeout(struct _timeout *to, _timeout_func_t fn,
k_ticks_t ticks = timeout.ticks + 1;

if (IS_ENABLED(CONFIG_TIMEOUT_64BIT) && Z_TICK_ABS(ticks) >= 0) {
ticks = Z_TICK_ABS(ticks) - (curr_tick + elapsed());
ticks = Z_TICK_ABS(timeout.ticks) - (curr_tick + elapsed());
}

__ASSERT(!sys_dnode_is_linked(&to->node), "");
Expand Down

0 comments on commit c4ad8e0

Please sign in to comment.