linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* jiffies wrap question...
@ 2000-11-10  7:21 Jeff Garzik
  2000-11-10  7:35 ` Philipp Rumpf
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Garzik @ 2000-11-10  7:21 UTC (permalink / raw)
  To: Linux Kernel Mailing List

The following is a piece of code from the latter half of
schedule_timeout, in kernel/sched.c.  Is it possible that
schedule_timeout could return an incorrect value, if the jiffy value
wraps between the first and last lines shown below.

        expire = timeout + jiffies;

        init_timer(&timer);
        timer.expires = expire;
        timer.data = (unsigned long) current;
        timer.function = process_timeout;

        add_timer(&timer);
        schedule();
        del_timer_sync(&timer);

        timeout = expire - jiffies;


-- 
Jeff Garzik             |
Building 1024           | Would you like a Twinkie?
MandrakeSoft            |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: jiffies wrap question...
  2000-11-10  7:21 jiffies wrap question Jeff Garzik
@ 2000-11-10  7:35 ` Philipp Rumpf
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Rumpf @ 2000-11-10  7:35 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Linux Kernel Mailing List

On Fri, Nov 10, 2000 at 02:21:28AM -0500, Jeff Garzik wrote:
> The following is a piece of code from the latter half of
> schedule_timeout, in kernel/sched.c.  Is it possible that
> schedule_timeout could return an incorrect value, if the jiffy value
> wraps between the first and last lines shown below.

let's say the first line happens n ticks before the wrap and the second,
m ticks afterwards.

>         expire = timeout + jiffies;

expire = timeout + 2^32/2^64 - n = timeout - n

>         timeout = expire - jiffies;

timeout = expire - m = timeout - n - m = timeout - (n+m)

(n+m) is the time that actually passed while we were asleep, and timeout
has the correct value (timeout - ticks that happened)>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-11-10  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-10  7:21 jiffies wrap question Jeff Garzik
2000-11-10  7:35 ` Philipp Rumpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).