LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Question on the condition parameter in wait_event_interruptible()
@ 2004-05-26 18:05 Parag Sharma
  0 siblings, 0 replies; only message in thread
From: Parag Sharma @ 2004-05-26 18:05 UTC (permalink / raw)
  To: linux-kernel

I looked at the kernel 2.4.21 sources and found that the 'condition' in 
calls to wait_event_interruptible() is usually a global variable. This 
global variable is updated before the wakeup is issued.
It is not clear to me how this update to the global variable is seen by the 
context that issued the wait_event_interruptible(). On certain processor 
architectures and on SMP systems, is it possible that the update is not 
reflected when the condition is tested in __wait_event_interruptible()?

If the answer to above is yes, then is it possible that there is a chance 
that a wakeup might be missed when the update & wakeup occur either before 
the call to add_wait_queue() or the call to 
set_current_state(TASK_INTERRUPTIBLE) in __wait_event_interruptible()?

Thanks,
Parag
PS: Please cc me on the reply.

#define __wait_event_interruptible(wq, condition, ret)                  \
do {                                                                    \
        wait_queue_t __wait;                                            \
        init_waitqueue_entry(&__wait, current);                         \
                                                                        \
        add_wait_queue(&wq, &__wait);                                   \
        for (;;) {                                                      \
                set_current_state(TASK_INTERRUPTIBLE);                  \
                if (condition)                                          \
                        break;                                          \
                if (!signal_pending(current)) {                         \
                        schedule();                                     \
                        continue;                                       \
                }                                                       \
                ret = -ERESTARTSYS;                                     \
                break;                                                  \
        }                                                               \
        current->state = TASK_RUNNING;                                  \
        remove_wait_queue(&wq, &__wait);                                \
} while (0)

_________________________________________________________________
Watch LIVE baseball games on your computer with MLB.TV, included with MSN 
Premium! http://join.msn.click-url.com/go/onm00200439ave/direct/01/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-05-26 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-26 18:05 Question on the condition parameter in wait_event_interruptible() Parag Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).