LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 08-07-2006, 04:28 PM   #1
Rawjoe
LQ Newbie
 
Registered: May 2006
Posts: 13

Rep: Reputation: 0
Jiffies


How does the linux Kernel know when to increment jiffies? Is it based on the processor or the RTC or something else I may not know? I was wondering so I would know where to look when determining the accuracy of jiffies. I see Hz is defined as 250, which is common for all x86, but how does it exactly know when 4 ms have gone by?

Thank you in advance.
 
Old 08-07-2006, 07:37 PM   #2
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Rep: Reputation: 45
Its based on the speed of your CPU. The kernel calculates jiffies, which are used to calculate BogoMIPS, which in turn are used to guess your CPU speed.
 
Old 08-07-2006, 09:44 PM   #3
Rawjoe
LQ Newbie
 
Registered: May 2006
Posts: 13

Original Poster
Rep: Reputation: 0
The kernel calculates jiffies, uses them to calculate bogomips, and uses that to guess the CPU speed. How does it calculate jiffies if it uses jiffies to guess the CPU speed?
 
Old 08-07-2006, 10:17 PM   #4
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Rep: Reputation: 45
When you boot the computer, you'll probably notice one of the lines reads

"Calibrating Delay Loop.... 3192.52 BogoMips"

The number isn't important and vary based upon the speed of processor. There is something called an internal delay loop. The goal is to see how many times this loop goes through between to timer ticks. I can't really explain it much better than this because I don't know much more than this myself. But the basic idea is a jiffy is used by the kernel to guess the CPU speed.

1.6G Pentium M = 3192.52 BogoMIPS = 6385059 Loop per jiffy

A jiffy is basicly just a unit of time. The more loops the kernel can complete in a "jiffY" the faster your processor is. But since humans work in terms of mhz and ghz, it goes through a series of calculations to convert that number to something more usuable.

Its called a BogoMIP because its a bogus calculation of how many millions of calculations you can do a second. Hence Bogo (bogus) MIPS(million instructions per second).
 
Old 08-07-2006, 10:25 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,448

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
Quote:
Originally Posted by Penguin of Wonder
... MIPS(million instructions per second).
Generally lampooned as "Meaningless Indicator of Processor Speed".
Now, when you also add "Bogus", you are really starting to get the idea.
 
Old 08-08-2006, 07:42 AM   #6
Rawjoe
LQ Newbie
 
Registered: May 2006
Posts: 13

Original Poster
Rep: Reputation: 0
So am I understanding this right?

The 250 Hz is arch dependent. The x86 family processors send an interrupt every 4ms (I think this is where I was lost). Linux sees this interrupt and tries to see how many loops it can execute before the next interrupt, allowing us to calculate BogoMIPS per jiffy and then CPU speed. So at boot time, Linux has no clue of actual CPU speed, just the fact that it knows it's an x86 and will receive that interrupt every 250 Hz. So then, the 250 Hz (and consequently the jiffies value) accuracy is dependent on the CPU crystal?

Update: Now that I look through the kernel compile, I see there is an option in the config file for that value, 100, 250, or 1000 HZ. Now I am confused again, because obviously the processor is not sending a signal every 250 Hz if this is a custom value. Maybe it sends it at 1 kHz and the kernel steps down?

Update: Think I've figured it out (finally). The 8254 PIT (used by x86) is a set 1.193181818181.... MHz. A register in the PIT is programed with a value determined by the HZ variable and it is used to determine when to signal IRQ 0, which in turn updates jiffies! I beleive I read somewhere that the 8254 PIT has an accuracy of +/- 100 ppm.

Last edited by Rawjoe; 08-08-2006 at 10:44 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jiffies a kernel only entity, or is it allowed in userspace also? pat_and_cami Programming 0 03-10-2006 12:36 AM
Kernel compiling problem, connected with jiffies.h zWaR Linux - Software 2 03-01-2006 05:30 PM
start date and start time of a process - jiffies Yoko Programming 0 12-04-2004 08:12 AM
questions about reference to "jiffies" carbooky Programming 4 04-12-2004 10:16 AM
How jiffies get updated? iikent Linux - Newbie 3 03-13-2004 08:36 AM


All times are GMT -5. The time now is 12:34 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration