From: "Darren Jenkins" <darrenrjenkins@gmail.com>
To: ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com
Cc: "Om N." <xhandle@gmail.com>,
kernel-janitors@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [KJ] [patch] fix common mistake in polling loops
Date: Thu, 10 Aug 2006 11:11:06 +1000 [thread overview]
Message-ID: <82faac5b0608091811v1217ac44i3e48006e4d1eed44@mail.gmail.com> (raw)
In-Reply-To: <200608092025.02259.ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com>
G'day,
On 8/10/06, Andrew James Wade <andrew.j.wade@gmail.com> wrote:
> You're getting duplicated code there. That'll be an issue in more
> complex loops. How about:
>
> unsigned long timeout = jiffies + HZ/2;
> int timeup = 0;
>
> for (;;;) {
> if (ready())
> return 0;
> if (timeup)
> break;
> msleep(10);
> timeup = time_after(timeout, jiffies);
> };
> ... timeout ...
>
Nice, looks better than my idea.
Removes the code duplication and reduces complexity(a little) at the
cost of an extra variable.
The only Nitpick is
- int timeup = 0;
+ unsigned char timeup = 0;
>
> Andrew Wade
Darren J.
next prev parent reply other threads:[~2006-08-10 1:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-28 8:28 Zed 0xff
2006-07-28 8:51 ` Jeff Garzik
2006-07-28 12:43 ` Dmitry Torokhov
2006-08-05 11:40 ` Pavel Machek
2006-08-05 11:45 ` Pavel Machek
2006-08-06 23:39 ` [KJ] " Darren Jenkins
2006-08-07 23:34 ` Pavel Machek
2006-08-08 0:53 ` Darren Jenkins
2006-08-08 2:53 ` Om N.
2006-08-10 0:25 ` Andrew James Wade
2006-08-10 1:11 ` Darren Jenkins [this message]
2006-08-08 9:19 ` Pavel Machek
[not found] <6DvTu-6tk-17@gated-at.bofh.it>
[not found] ` <6Ho72-7do-3@gated-at.bofh.it>
[not found] ` <6HpZd-1vB-19@gated-at.bofh.it>
[not found] ` <6I6B4-72S-7@gated-at.bofh.it>
[not found] ` <6I7np-8bD-11@gated-at.bofh.it>
2006-08-10 11:58 ` Bodo Eggert
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=82faac5b0608091811v1217ac44i3e48006e4d1eed44@mail.gmail.com \
--to=darrenrjenkins@gmail.com \
--cc=ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com \
--cc=kernel-janitors@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xhandle@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
all inboxes | Powered by JetHome®