lkml.org 
[lkml]   [2005]   [Dec]   [27]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromBodo Eggert <>
SubjectRe: something about jiffies wraparound overflow
DateTue, 27 Dec 2005 11:06:05 +0100
jeff shia <tshxiayu@gmail.com> wrote:

> 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)

[...]

> But I cannot understand it has some differences comparing with the
> following code.> > /* code 2*/> > unsigned long timeout = jiffies + HZ/2;> > if(timeout < jiffies)

> questions:>   1.why the macros of time_after can solve the jiffies wraparound problem?

Because the overflows get compensated. It's a property of Galois Fields.

>   2.Is there any other possibilities for the "code 2" to overflow
> except the jiffies overflow?

timeout might overflow, too.
-- 
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-27 11:07    [from the cache]
©2003-2008