All of lore.kernel.org
 help / color / mirror / Atom feed
* something about jiffies wraparound overflow
@ 2005-12-27  4:46 jeff shia
  2005-12-27  8:54 ` lk
  2005-12-27 14:54 ` Ben Collins
  0 siblings, 2 replies; 5+ messages in thread
From: jeff shia @ 2005-12-27  4:46 UTC (permalink / raw)
  To: linux-kernel, robert love

 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <5oeWK-5Od-11@gated-at.bofh.it>]

end of thread, other threads:[~2005-12-27 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-27  4:46 something about jiffies wraparound overflow jeff shia
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.