Skip to contentSkip to conversation

something about jiffies wraparound overflow

DISCUSSION Bodo Eggert 1 participant 1 message Dec 27, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines · jeff shia

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)

[...]

Quoted 11 lines

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.

Quoted 2 lines

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

timeout might overflow, too.

Signature · 2 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.