From: George Anzinger <george@mvista.com>
To: root@chaos.analogic.com
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: timing code in 2.6.1
Date: Tue, 20 Jan 2004 01:59:41 -0800 [thread overview]
Message-ID: <400CFC0D.4020000@mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.53.0401190849230.6524@chaos>
Richard B. Johnson wrote:
> On Fri, 16 Jan 2004, Andrew Morton wrote:
>
>
>>"Richard B. Johnson" <root@chaos.analogic.com> wrote:
>>
>>>
>>>Some drivers are being re-written for 2.6++. The following
>>>construct seems to work for "waiting for an event" in
>>>the kernel modules.
>>>
>>> // No locks are being held
>>> tim = jiffies + EVENT_TIMEOUT;
>>> while(!event() && time_before(jiffies, tim))
>>> schedule_timeout(0);
>>>
>>>Is there anything wrong?
>>
>>This is not a good thing to be doing. You should add this task to a
>>waitqueue and then sleep. Make the code which causes event() to come true
>>deliver a wake_up to that waitqueue. There are many examples of this in
>>the kernel.
>>
>
>
> Huh? The code that causes "event()" needs to get the CPU occasionally
> to check for the event. The hardware doesn't produce an interrupt
> upon that event.
THAT is where the hardware designer went wrong. An interrupt is really the best
way for hardware to notify the cpu of an event. Details may then be read from
hardware registers, if needed.
The request of a 0 timeout is really asking for a timeout on the last jiffie. I
suspect that relying on this to actually not happen until the next jiffie is NOT
a good thing. I am not aware of any spec that says that is what it should do
and I am aware of timer patchs that will run the timer immeadiatly. A request
for 1 jiffie will do the same thing in the current kernel AND under that patch.
That thing being, by the way, is to wait for the next jiffie which will be any
time from ~0 to 1 jiffie.
>
Lots of words, which did not explain why an interrupt was not used to signal the
event, deleted :)
--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
next prev parent reply other threads:[~2004-01-20 10:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-16 16:51 timing code in 2.6.1 Richard B. Johnson
2004-01-16 23:31 ` Andrew Morton
2004-01-19 14:11 ` Richard B. Johnson
2004-01-20 9:59 ` George Anzinger [this message]
2004-01-22 2:26 ` Jamie Lokier
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=400CFC0D.4020000@mvista.com \
--to=george@mvista.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.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