[Asterisk-Dev] what's the value of a jiffie in zaptel driver
?
Gilad Ben-Yossef
gilad at codefidence.com
Mon Nov 22 09:46:26 MST 2004
Dinesh Nair wrote:
>
> hi all,
>
> i'm trying to reconcile the register settings and proslic calibration
> procedure for the wcfxs/wctdm driver between the linux zaptel drivers
> and the freebsd zaptel drivers. i'm pretty much sure that a lot of the
> problems is timing (i.e. wait/sleep time) based differences and a lot of
> this is due to the assumption of what the variable jiffie contains.
>
> i do believe that it is the number of clock ticks, however what's the
> frequency of the clock ticks ? is it 100 per second or 1000 per second ?
> this has a vast difference when used in code like this:
>
> origjiffies=jiffies;
> while((jiffies-origjiffies)<4);
>
> is the above while looping for 4ms or 40ms ? the lack of comments in the
> file make it difficult to port, for freebsd's clock ticks are defined by
> the HZ kernel variable, which by default is set to 100, but can be
> increased (and is usually increased) to 1000 for performance sensitive
> deployments.
>
> can anyone assist in clarifying what a jiffie is ?
>
Under Linux the jiffies variable is the number of clock ticks since the
machine boot. It's rate is defined by (surprise, surprise...) the HZ
define from the kernel param.h
For a normal (as in - not patched) Linux kernel of versions 2.4.x the
value of HZ is 100 for the x86 platform and a 1000 for the PowerPC
platform. Since version 2.6 the x86 port also has a value of 1000 for HZ
by default. Patches exist to make these variable during compile time.
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... :-)
Hope this helped, or at least confused you in a pleasurable fashion.
Cheers,
Gilad
--
Gilad Ben-Yossef <gilad at codefidence.com>
Codefidence. A name you can trust(tm)
Web: http://codefidence.com | SIP: gilad at pbx.codefidence.com
Tel: +972.9.8650475 ext. 201 | Fax: +972.9.8850643
"I am Jack's Overwritten Stack Pointer"
-- Hackers Club, the movie
More information about the asterisk-dev
mailing list