lkml.org 
[lkml]   [2004]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] WAIT_BIT_QUEUE


On Mon, 10 May 2004, Oleg Nesterov wrote:
>
> so there is no need to recheck the bit in do/while loop, because
> there is no false wakeups now.

You should never assume this. You should assume that there are _always_
false wakeups.

Why? Because Linux has always allowed people to leave wait-queues active,
without being "atomic". For example, the tty read/write layer used to
(still does?) add itself on the wait-queue _once_, and then leave itself
on the wait-queue while in a loop it does copies from/to user space.

Which means that you can get wake-ups from totally unrelated _other_
sources while you're doing IO.

Never EVER assume (and depend on) that you only get one wakeup. It may be
the most common case by far, but it's not guaranteed. If you slept waiting
for something, then you should re-check that something when you wake up.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-11-18 23:46    [W:0.028 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site