nanogui: where to fix timer bug
Subject:
Re: [nanogui] where to fix timer bug
From:
Alex Holden ####@####.####
Date:
4 Jul 2004 08:52:29 +0100
Message-Id: <40E7B6CC.4060606@linuxhacker.org>
tj wrote:
> Where in the nano-X code are the timer IDs processed and timer events
> displatched? I might take a look and try to patch it to work in the
> above conditions.
Look at the UNIX version of GsSelect in nanox/srvmain.c. It calls
GdGetNextTimeout() to find out how long it is till the next timer
expires (hence how long it should use as the timeout value for the
select()), and then calls GdTimeout() when the select() times out. Both
of these functions are in engine/devtimer.c. It looks to me like
devtimer.c : time_to_expiry() has a couple of problems. Firstly
MWTIMEOUT is unsigned but we should really be using a signed type here
because the result can be negative (I wonder why the compiler didn't
warn about the return from unsigned to signed without a cast? Or maybe
MWTIMEOUT only recently changed to unsigned?). Secondly even if you fix
that the result of the calculation will overflow anyway if the two
timers are more than a couple of billion milliseconds apart (about 25
days). Which shouldn't happen normally but will if ntpdate makes your
clock jump forward 34 years or you put your laptop to sleep for a few
weeks then wake it up again.
Fixing it is left as an exercise to the reader...
--
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer