Subj : Re: usage of time() for timeout handling To : comp.arch.embedded,comp.programming From : Hans-Bernhard Broeker Date : Thu Jul 28 2005 12:17 pm [F'up2 cut down.] In comp.arch.embedded David wrote: > Hi gurus, > I'm having some modules, that use time() for determine if a given activity > has timed out. As the operating system time will be updated periodically > with the time or the RTC chip, it is possible that the result of two calls > to time() would give a smaller value on the second call. But only by user intervention --- the automatic timer update will step backwards only once, ever (sometime in 2038 typically). That's one reason why you shouldn't use time() for this unless you have absolutely no other option. Even clock() will generally be better than time(). > This would cause the timeout calculation to fail and result in > unexpected behaviour. Only if you did wrongly. > This situation could specially occour if the user changed the time of the > system! How are you handling this problem? For the embedded world: by not allowing the users to get his dirty hands on internal timer values. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain. .