* Add wait_event_timeout()
@ 2004-09-25 9:13 Russell King
2004-09-25 9:42 ` Jon Masters
0 siblings, 1 reply; 6+ messages in thread
From: Russell King @ 2004-09-25 9:13 UTC (permalink / raw)
To: linux-kernel, akpm
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); \
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add wait_event_timeout()
2004-09-25 9:13 Add wait_event_timeout() Russell King
@ 2004-09-25 9:42 ` Jon Masters
2004-09-25 9:44 ` Jon Masters
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jon Masters @ 2004-09-25 9:42 UTC (permalink / raw)
To: Russell King; +Cc: linux-kernel, akpm
On Sat, 25 Sep 2004 10:13:59 +0100, Russell King <rmk@arm.linux.org.uk> wrote:
> There appears to be one case missing from the wait_event() family -
> the uninterruptible timeout wait. The following patch adds this.
Any reason it's called wait_event_timeout then rather than
wait_event_uninterruptible_timeout?
Jon.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add wait_event_timeout()
2004-09-25 9:42 ` Jon Masters
@ 2004-09-25 9:44 ` Jon Masters
2004-09-25 9:44 ` William Lee Irwin III
2004-09-25 9:56 ` Russell King
2 siblings, 0 replies; 6+ messages in thread
From: Jon Masters @ 2004-09-25 9:44 UTC (permalink / raw)
To: Russell King; +Cc: linux-kernel, akpm
On Sat, 25 Sep 2004 10:42:15 +0100, Jon Masters <jonmasters@gmail.com> wrote:
> Any reason it's called wait_event_timeout then rather than
> wait_event_uninterruptible_timeout?
Aside from that. I think this is pretty handy to have around - I've
got some very buggy hardware right now which benefits from the odd
hard kick in its soft-core behind.
Jon.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add wait_event_timeout()
2004-09-25 9:42 ` 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
2 siblings, 1 reply; 6+ messages in thread
From: William Lee Irwin III @ 2004-09-25 9:44 UTC (permalink / raw)
To: Jon Masters; +Cc: Russell King, linux-kernel, akpm
On Sat, 25 Sep 2004 10:13:59 +0100, Russell King <rmk@arm.linux.org.uk> wrote:
>> There appears to be one case missing from the wait_event() family -
>> the uninterruptible timeout wait. The following patch adds this.
On Sat, Sep 25, 2004 at 10:42:15AM +0100, Jon Masters wrote:
> Any reason it's called wait_event_timeout then rather than
> wait_event_uninterruptible_timeout?
Anything interruptible is explicitly tagged as such; the "default",
sadly enough, is uninterruptible.
-- wli
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add wait_event_timeout()
2004-09-25 9:44 ` William Lee Irwin III
@ 2004-09-25 9:52 ` Jon Masters
0 siblings, 0 replies; 6+ messages in thread
From: Jon Masters @ 2004-09-25 9:52 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: Russell King, linux-kernel, akpm
On Sat, 25 Sep 2004 02:44:45 -0700, William Lee Irwin III
<wli@holomorphy.com> wrote:
> Anything interruptible is explicitly tagged as such; the "default",
> sadly enough, is uninterruptible.
Fair enough, if that's the reasoning, then ok (I've never given that
much thought). Oh well...
Jon.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Add wait_event_timeout()
2004-09-25 9:42 ` Jon Masters
2004-09-25 9:44 ` Jon Masters
2004-09-25 9:44 ` William Lee Irwin III
@ 2004-09-25 9:56 ` Russell King
2 siblings, 0 replies; 6+ messages in thread
From: Russell King @ 2004-09-25 9:56 UTC (permalink / raw)
To: jonathan; +Cc: linux-kernel, akpm
On Sat, Sep 25, 2004 at 10:42:15AM +0100, Jon Masters wrote:
> On Sat, 25 Sep 2004 10:13:59 +0100, Russell King <rmk@arm.linux.org.uk> wrote:
>
> > There appears to be one case missing from the wait_event() family -
> > the uninterruptible timeout wait. The following patch adds this.
>
>
> Any reason it's called wait_event_timeout then rather than
> wait_event_uninterruptible_timeout?
Because I chose to follow the existing naming scheme.
wait_event() - uninterruptible wait
wait_event_interruptible() - interruptible wait
wait_event_interruptible_timeout() - interruptible wait with timeout
so, the uninterruptible wait with timeout can only logically be:
wait_event_timeout()
Lets not go starting a new naming scheme. 8)
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-09-25 9:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-25 9:13 Add wait_event_timeout() Russell King
2004-09-25 9:42 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox