Re: why kernel implement "udelay" by cpu instructions?
From: Bryan Donlan
Date: Wed Nov 04 2009 - 00:37:19 EST
On Wed, Nov 4, 2009 at 12:01 AM, Rajat Jain <Rajat.Jain@xxxxxxxxxxxx> wrote:
>> 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.
I thought hrtimers allow higher-precision wakeups these days?
Of course, if you only want to sleep for a few microseconds, the
context switch might take longer than you want to sleep...
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/