delay_timer by Linux kernel

Status
Not open for further replies.

tapas_mishra

Newbie level 2
Joined
Apr 2, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
Hi I am new to this forum ,want to know that how does the processor timer gets recognized by Linux kernel.
There is a variable known as jiffy which stores the number of timer ticks a computer has been run and up since its boot.
Here is a link to the article that I am asking.

http://kerneltrap.org/node/6857

I am trying to generate a delay of the order of 10^-9 although the code exists on what I am asking but want to do it myself.
Here is a link to the code I am referring to if some one wants to see.
**broken link removed**

What I want to know is which register does the kernel reads to get the value of variable jiffy ? Is it random or well defined location?
 

Originally the JIFFY was the time interval between system timer interrupts, however today it's referred to as the software clock and based on the kernel variable HZ. The value of HZ ranges from 1ms to 10ms, depending on the speed of the processor with 4ms being the default. JIFFIES is the running count of each JIFFY.

The kernel offers two delay functions mdelay() and udelay(), delays of 10^-3 and 10^-6 respectfully, far short of your desired nanosecond or 10^-9. Delays of that fine a granularity are not feasible or for that matter possible with any OS even a RTOS running on the processor. You would have to write a routine in assembler counting each and every clock cycle used by your code and then dedicating the entire processor to running only your code. Besides system buses typically run slower than 1GHz so what can you accomplish even if you achieved an accurate 1ns delay? The clock cycle on a 1GHz x86 is 1ns, even delays of single digit microseconds can be a challenge on many linux machines, due to the fact that linux is not a true RTOS.


This is why there is no ndelay() kernel function available. You'll just have to wait for the Intel Optical Processors due out next year. Remember 3x10^8 m/s, it not just a good idea, it's the law.
 
bigdogguru said:
You would have to write a routine in assembler counting each and every clock cycle used by your code and then dedicating the entire processor to running only your code.
Hi thanks for the nice explanation.If you can point me out to the some code as you mentioned above I would like to read or what should I search for.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…