Commit 980b0e17 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: make timeout periods more precise

Use last timeout's timestamp as a reference for new timeout instead of current
Signed-off-by: Adam Wujek's avatarAdam Wujek <>
parent 7e4799f3
......@@ -18,10 +18,12 @@ int libwr_tmo_restart(timeout_t *tmo)
int libwr_tmo_expired(timeout_t *tmo)
int expired = (get_monotonic_us() - tmo->start_tics > tmo->timeout);
uint64_t time = get_monotonic_us();
int expired = (time > tmo->start_tics + tmo->timeout);
if (tmo->repeat && expired)
tmo->start_tics = get_monotonic_us();
while (time > tmo->start_tics + tmo->timeout)
tmo->start_tics += tmo->timeout;
return expired;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment