lkml.org 
[lkml]   [2009]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: why kernel implement "udelay" by cpu instructions?
Date
From
Hi,

> I find something interesting; kernel has msleep, but it
> doesn't have usleep.
> Does that mean the minimum time kernel can react is msecond
> instead of usecond?
> so if users want to count useconds, they have to do the busy waiting,
> execute some looping assembly instructions?

You are roughly right. If you don't want to busy loop (udelay / mdelay), then you will have to sleep. The granularity of this sleep depends on how frequently the timer interrupt ticks (HZ). Thus if HZ is 1000, then you cannot sleep for a period less than 1 msec.

>
> If my consumption is correct, where I can find the evidence?
> BTW, does Hz has anything related to kernel timing?
> From the comment in the kernel, it says
> Hz: clock ticks generated per second
> Does that mean the kernel will get #Hz timer interrupts per second?

Yes.

> Whz the value of Hz is 100? if the minimum reaction time of kernel is
> msecond, the value of Hz should be 1000, right?

Default value of HZ depends on the architecture - and you can change it as well. If HZ is 100, then minimum sleep is 10 ms. If you call msleep(1), you will still sleep for 10 msec atleast - msleep() only guarantees that you will sleep for ATLEAST the time you specified - you may obviously sleep for longer.

>>
>> At bootup the kernel measures the delay loop speed of
>> each CPU.  CPU frequency scaling might make the loop
>
> would you please let me know where the source code is?
> (measuring loop speed of cpu and scale cpu frequency)

calibrate_delay()


Thanks,

Rajat
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-11-04 06:21    [W:0.063 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site