From: Rik van Riel <riel@redhat.com>
To: loody <miloody@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Kernel Newbies <kernelnewbies@nl.linux.org>
Subject: Re: why kernel implement "udelay" by cpu instructions?
Date: Sun, 01 Nov 2009 23:45:22 -0500 [thread overview]
Message-ID: <4AEE63E2.9010003@redhat.com> (raw)
In-Reply-To: <3a665c760911011913q268b010cqb5da4f79df995b9b@mail.gmail.com>
On 11/01/2009 10:13 PM, loody wrote:
> Dear all:
> I find the kernel use cpu instruction to implement the udelay function
> as keeping decrease a big counter by 1.
>
> If I search the right place in kernel, why kernel does so?
Because udelay is used in places where the kernel cannot
use other mechanisms, eg. because interrupts are blocked
or the current process cannot be scheduled out.
> the precision will be different if cpu runs faster or slower, right?
At bootup the kernel measures the delay loop speed of
each CPU. CPU frequency scaling might make the loop
run slower at times, but that is okay because udelay
simply specifies a *minimum* delay.
This is true even on systems without frequency scaling,
because the udelay loop could be interrupted by an
interrupt, an NMI or by having the CPU trap into SMM
mode and execute code there.
--
All rights reversed.
next prev parent reply other threads:[~2009-11-02 4:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 3:13 why kernel implement "udelay" by cpu instructions? loody
2009-11-02 4:45 ` Rik van Riel [this message]
2009-11-04 2:19 ` loody
2009-11-04 5:01 ` Rajat Jain
2009-11-04 5:36 ` Bryan Donlan
2009-11-04 5:45 ` Rajat Jain
2009-11-04 14:16 ` Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AEE63E2.9010003@redhat.com \
--to=riel@redhat.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miloody@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox