lkml.org 
[lkml]   [2005]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectsomething about jiffies wraparound overflow
 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.
-
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 05:48    [W:2.342 / U:0.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site