RE: why kernel implement "udelay" by cpu instructions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux