Messages in this thread | | | Date | Wed, 3 Dec 2008 17:09:07 +0100 (CET) | From | Roman Zippel <> | Subject | Re: [RFC][PATCH] Catch xtime_nsec underflows and fix them |
| |
Hi,
On Wed, 3 Dec 2008, Zhang, Yanmin wrote:
> > > When xtime_nsec underflows at the first time, xtime.tv_nsec becomes -1. > > > Later on when the second tick arrives, below statement in the while loop > > > clock->xtime_nsec += clock->xtime_interval; > > > will cause clock->xtime_nsec becomes positive again. So the second tick > > > appears a going-backward time. > > > > Yes, but only by 1nsec, so normally it wouldn't be noticable. > Not 1nsec. At the second tick, go back about 4294967296 nsec (2^32), about > 4 seconds. That matches the output of testing process.
Above code is not the problem. The error appeared in do_vgettimeofday() as it only uses unsigned values, so the -1 became 0xffffffff in nsec and the clock jumped forward 4 seconds and a tick later 4 seconds back.
bye, Roman | |