[Asterisk-Dev] what's the value of a jiffie in zaptel driver ?

Peter Svensson psvasterisk at psv.nu
Mon Nov 22 10:05:40 MST 2004


On Mon, 22 Nov 2004, Gilad Ben-Yossef wrote:

> Dinesh Nair wrote:
> >         origjiffies=jiffies;
> >         while((jiffies-origjiffies)<4);

[snip]
> One issue that is very important to consider is "jiffie warp". The 
> jiffie is a 32 bit value, which means it will wrap around somewhere 
> after a year for kernel 2.4/x86 and much sooner for 2.6 kernels or on 
> the powerpc.
> 
> In the 2.6 series a jiffie_64 (or something similar, I don't remember) 
> symbol exists, but on 32 bit arch's like the x86 it is not possible to 
> read this value atomically without holding a lock. The regular jiffies 
> symbols is really the 32 bit LSB of 64 bit jiffies value.
> 
> What all this means is the code snippet above is broken and will fail 
> when the jiffies will wrap around causing untold damage to your machine, 
> life and telephony equipment, but maybe not in that order... :-)

Actually it works nicely event at wrap around time, as long as the result 
of the subtraction is a signed operation. Actually, I think there are 
macros in the kernel that make sure the variables are cast correctly. 

Peter




More information about the asterisk-dev mailing list