Messages in this thread | | | Date | Mon, 10 May 2004 07:55:18 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [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/
| |