halayli / lthread

lthread, a multicore enabled coroutine library written in C
Other
814 stars 82 forks source link

Should use monotonic clock instead of gettimeofday #37

Open baruch opened 9 years ago

baruch commented 9 years ago

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.