From: Russell King <rmk@arm.linux.org.uk>
To: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Add wait_event_timeout()
Date: Sat, 25 Sep 2004 10:13:59 +0100 [thread overview]
Message-ID: <20040925091359.GA4431@dyn-67.arm.linux.org.uk> (raw)
There appears to be one case missing from the wait_event() family -
the uninterruptible timeout wait. The following patch adds this.
This wait is particularly useful when (eg) you wish to pass work off
to an interrupt handler to perform, but also want to know if the
hardware has decided to go gaga under you. You don't want to sit
around waiting for something that'll never happen - you want to go
and wack the gremlin which caused the failure and retry.
--- linux/include/linux/wait.h.orig 2004-09-21 13:07:07.000000000 +0100
+++ linux/include/linux/wait.h 2004-09-25 09:33:19.000000000 +0100
@@ -156,6 +156,29 @@
__wait_event(wq, condition); \
} while (0)
+#define __wait_event_timeout(wq, condition, ret) \
+do { \
+ DEFINE_WAIT(__wait); \
+ \
+ for (;;) { \
+ prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ ret = schedule_timeout(ret); \
+ if (!ret) \
+ break; \
+ } \
+ finish_wait(&wq, &__wait); \
+} while (0)
+
+#define wait_event_timeout(wq, condition, timeout) \
+({ \
+ long __ret = timeout; \
+ if (!(condition)) \
+ __wait_event_timeout(wq, condition, __ret); \
+ __ret; \
+})
+
#define __wait_event_interruptible(wq, condition, ret) \
do { \
DEFINE_WAIT(__wait); \
next reply other threads:[~2004-09-25 9:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-25 9:13 Russell King [this message]
2004-09-25 9:42 ` Add wait_event_timeout() Jon Masters
2004-09-25 9:44 ` Jon Masters
2004-09-25 9:44 ` William Lee Irwin III
2004-09-25 9:52 ` Jon Masters
2004-09-25 9:56 ` Russell King
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=20040925091359.GA4431@dyn-67.arm.linux.org.uk \
--to=rmk@arm.linux.org.uk \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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