-
- Downloads
clock: base timers on monotonic clock
sched::timer_base, used to implement all forms of timeouts in OSv, is currently based on the wall-clock time in s64 form. This is problematic for two reasons: 1. The type s64 doesn't say which units should be used, whether the time is absolute or relative or what is its epoch. 2. wall-clock time is a bad choice for short-term timers: If a thread intends to sleep for a millisecond, and the wall-clock goes back a minute, the thread will end up sleeping a whole minute. So this patch changes the basis of sched::timer_base to strongly-typed time points from a monotonic clock, osv::clock::uptime::time_point. We also allow setting timers using the wall-clock time, but with a big caveat: The expiration time is converted from wall to uptime clocks at the moment of timer_base::set(), so if the wall-clock is adjusted later, the wall time at expiration may not be exactly the one intended. So that we don't have to change all timer users in this one patch, we also temporarily implement the old weakly-typed timer_base::set(s64) using the new mechanism. This variant will be removed in a later patch in this series, when it is no longer used. Reviewed-by:Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
Loading
Please register or sign in to comment