lthread
lthread copied to clipboard
Should use monotonic clock instead of gettimeofday
The result of gettimeofday is the wall clock which can change backwards in some occassions (time drifted and ntp re-enabled). In that case timeouts may not expire for a while until the wall clock catches up.
It is better to use CLOCK_MONOTONIC with clock_gettime() to get a stable clock that never moves backwards.