[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <C86899CCB10A6C4E93D5978DCB232D4B0D754B62@GDCMX01.igglobal.com>
Date: Wed, 4 Nov 2009 10:31:17 +0530
From: "Rajat Jain" <Rajat.Jain@...ogain.com>
To: "loody" <miloody@...il.com>, "Rik van Riel" <riel@...hat.com>
Cc: <linux-kernel@...r.kernel.org>,
"Kernel Newbies" <kernelnewbies@...linux.org>
Subject: RE: why kernel implement "udelay" by cpu instructions?
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists