kernel/timeout: fix k_timer_remaining_get() when tickless
In some circumstances (e.g., a tickless kernel), k_timer_remaining_get() would not account for time passed that didn't involve clock interrupts. This adds a simple fix for that, and adds a test case. In addition, the return value of k_timer_remaining_get() is clamped at 0 in the case of overdue timers and the API description is adjusted to reflect this. Fixes: #13353 Signed-off-by: Charles E. Youse <charles.youse@intel.com>
This commit is contained in:
parent
10040f603d
commit
0ad4022e51
4 changed files with 34 additions and 4 deletions
|
@ -1561,7 +1561,8 @@ __syscall u32_t k_timer_remaining_get(struct k_timer *timer);
|
|||
|
||||
static inline u32_t _impl_k_timer_remaining_get(struct k_timer *timer)
|
||||
{
|
||||
return (u32_t)__ticks_to_ms(z_timeout_remaining(&timer->timeout));
|
||||
const s32_t ticks = z_timeout_remaining(&timer->timeout);
|
||||
return (ticks > 0) ? (u32_t)__ticks_to_ms(ticks) : 0U;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue