Re: function g_cond_timed_wait is not safe when change of datetime?



On Fri, 21 Nov 2008 14:45:35 +0200
"Tor Lillqvist" <tml iki fi> wrote:
> > The system clock can be altered by a privileged user (for obvious
> > reasons - you need to be able to set it to the current time every
> > now and then to accommodate clock drift).
> 
> Isn't that handled on modern systems (once the time has been set
> roughly correct, typically at boot time, to within a minute, say) by
> just speeding up or slowing down the clock, not by stepping it? See
> adjtime(). SetSystemTimeAdjustment() seems to be the corresponding
> thing on Win32.

Yes indeed, I chose a bad example.  Unix-like systems however
also provide the settimeofday() function (although neither it nor
adjtime() appear to be actually required by Posix), and they also
provide a 'date' user command which can manipulate the system clock.

The way to guard against these is to use a monotonic clock on timed
blocking function calls such as timed condition variable waits.

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]