Re: [Patch] Re: Nasty suprise with uptime

Petr Vandrovec
2001-11-01T08:03:54Z

On 1 Nov 01 at 1:52, Tim Schmielau wrote:

> + static unsigned long jiffies_hi = 0;
> + static unsigned long jiffies_last = INITIAL_JIFFIES;
> + unsigned long jiffies_tmp;
> +
> + jiffies_tmp = jiffies; /* avoid races */
> + if (jiffies_tmp < jiffies_last) /* We have a wrap */
> + jiffies_hi++;
> + jiffies_last = jiffies_tmp;

There is very small race - if two processes will call get_jiffies64()
at same time, they can both happen to test jiffies_tmp < jiffies_last
with old jiffies_last - incrementing jiffies_hi twice :-( This race
window is only few microseconds every 497 days, but if we want
correct kernel...
Best regards,
Petr Vandrovec
vandrove@vc.cvut.cz