mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: jeff shia <tshxiayu@gmail.com>
To: linux-kernel@vger.kernel.org, robert love <rml@novell.com>
Subject: something about jiffies wraparound overflow
Date: Tue, 27 Dec 2005 12:46:14 +0800	[thread overview]
Message-ID: <7cd5d4b40512262046w6f7a8161jfaf1e618e5722b4@mail.gmail.com> (raw)

 Hello,

we use the following to solve the problem of jiffies wraparound.
#define time_after(a,b)		\
	(typecheck(unsigned long, a) && \
	 typecheck(unsigned long, b) && \
	 ((long)(b) - (long)(a) < 0))
#define time_before(a,b)	time_after(b,a)

#define time_after_eq(a,b)	\
	(typecheck(unsigned long, a) && \
	 typecheck(unsigned long, b) && \
	 ((long)(a) - (long)(b) >= 0))
#define time_before_eq(a,b)	time_after_eq(b,a)

But I cannot understand it has some differences comparing with the
following code.

/* code 2*/

unsigned long timeout = jiffies + HZ/2;

if(timeout < jiffies)
{
        /* not timeout...*/
}
else
{
        /* timeout processing...*/
}

questions:
  1.why the macros of time_after can solve the jiffies wraparound problem?
  2.Is there any other possibilities for the "code 2" to overflow
except the jiffies overflow?

Any help will be preferred .
Thank you,


Yours.

             reply	other threads:[~2005-12-27  4:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-27  4:46 jeff shia [this message]
2005-12-27  8:54 ` lk
2005-12-27  9:05   ` Con Kolivas
2005-12-27 14:54 ` Ben Collins
     [not found] <5oeWK-5Od-11@gated-at.bofh.it>
2005-12-27 10:06 ` Bodo Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cd5d4b40512262046w6f7a8161jfaf1e618e5722b4@mail.gmail.com \
    --to=tshxiayu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®