2005-04-14 09:49:38

by Thomas Koeller

[permalink] [raw]
Subject: need advice about wait queue usage

Can anybody on this list answer the following question:

My code contains a call to wait_event_interruptible_exclusive().
This results in the current task going to sleep on a wait queue.
It builds a wait_queue_t struct in its current stack frame,
setting the .func member to autoremove_wake_function(), adds it
to the wait queue, and finally reschedules.

At a later point in time, another thread calls wake_up_interruptible()
on the wait queue. This results in a call to autoremove_wake_function(),
which in turn calls default_wake_function(), which then calls
try_to_wake_up(). At this point, the previously sleeping task becomes
runnable again. Then, after default_wake_function() returns,
list_del_init() is called to remove the wait_queue_t from the
wait queue.

Now, since the wait_queue_t is allocated in the stack frame of the
just woken-up task, which could already be running at this point,
how can I be sure that the wait_queue_t is still valid at the point
list_del_init() is called to remove it from the wait queue? It
seems to me that I cannot and hence autoremove_wake_function() is
broken, or am I missing something?

Any responders pls. cc me; I am not subscribed to this list.

thanks,
Thomas
--
--------------------------------------------------

Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com
http://www.baslerweb.com

==============================