kernel: Fixes sys_clock_tick_get()

Fixes an issue in sys_clock_tick_get() that could lead to drift in
a k_timer handler. The handler is invoked in the timer ISR as a
callback in sys_tick_announce().
  1. The handler invokes k_uptime_ticks().
  2. k_uptime_ticks() invokes sys_clock_tick_get().
  3. sys_clock_tick_get() must call elapsed() and not
     sys_clock_elapsed() as we do not want to count any
     unannounced ticks that may have elapsed while
     processing the timer ISR.

Fixes #46378

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2022-08-03 16:11:32 -04:00 committed by Anas Nashif
parent 8e55e59c59
commit 71ef669ea4

View file

@ -289,7 +289,7 @@ int64_t sys_clock_tick_get(void)
uint64_t t = 0U; uint64_t t = 0U;
LOCKED(&timeout_lock) { LOCKED(&timeout_lock) {
t = curr_tick + sys_clock_elapsed(); t = curr_tick + elapsed();
} }
return t; return t;
} }