clocksource, clockevent, jiffies
Hi all,
What are the relations between clocksourcem clockevent and jiffies? I looked at the kernel source code but it's hard to understand. Can someone gives a brief to top level explanation? Thanks, Wei Xu |
Quote:
The following should be included with the kernel source, but it provides an overview of how timekeeping is used. https://www.kernel.org/doc/Documenta...imekeeping.txt |
Hi,
So is jiffies based on clocksource or clockevent? Thanks, Wei Xu Quote:
|
Quote:
Since it depends on the environment, the "bogomips" values got used to create a fictitious speed that could be used for very low level spinwaits. A request for a millisecond (or less) would go into a loop for a fixed count - computed from the bogomips speed for the given CPU. Not perfect, but it allows things to work where there are no interrupts. |
Hi,
When I look at how jiffies is implemented, i saw the following code: # define jiffies raid6_jiffies() static inline uint32_t raid6_jiffies(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec*1000 + tv.tv_usec/1000; } Looks like it call gettimeofday() to get the elapsed time then return the second *1000 and micor_second/1000. My question is, why multiply the second by 1000 is hard coded? doesn't jiffies depends on #define HZ xxx in other words, if I redefine HZ to other value, could than not make the factor 1000 invalid? Thanks, Wei Xu Quote:
|
Quote:
Here, a jiffy is being defined from the timeval structure (manpage gettimeofday): Code:
struct timeval { The result is a monotonically increasing count. It just happens that the 1000 is the same value as the Hz value - but is not related. The units being computed are milliseconds, so changing the values by 1000. I believe in this case the count is used to set generations of the raid 6 data structures to identify out-of-date data blocks that are in error, and a millisecond is judged to be short enough to make that determination. The "jiffy" in this case is the minimum time between generations of data blocks before an error has occured, which happens to be units of 1 millisecond. As before, a "jiffy" is just a minimum amount of time a given clock can detect. In this case, 1 millisecond. |
All times are GMT -5. The time now is 06:43 PM. |