__wait_event_interruptible question
From: Capstar (spam0_at_deleg.homeip.net)
Date: 02/16/04
- Next message: Markus Kossmann: "Re: Silicon image sata controler"
- Previous message: nickel: "Linux driver about a PCI/SCSI device"
- Next in thread: Kasper Dupont: "Re: __wait_event_interruptible question"
- Reply: Kasper Dupont: "Re: __wait_event_interruptible question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Feb 2004 16:25:40 +0100
Hi NG,
I got the next macro from sched.h from kernel 2.4.23_pre5.
#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)
This macro is internally used by wait_event_interruptible and is used to
wait for a condition to become true without polling it. SO what happens
is that the current process is added to a waitq specified in
wait_event_interruptible. After that it is set to TASK_INTERRUPTIBLE
and, if the condition is not yet met, the process is scheduled.
So what worries me a bit is that if the wake_up_interruptible is called
from an interrupt service routine, I think it is possible that the
process never get woken up.
Let me explain. If the interrupt occurs right between the add_wait_queue
ad the set_current_state, the state will be set to TASK_RUNNING by
wake_up_interruptible in the ISR. Then the isr returns, and the process
will be set to TASK_INTERRUPTIBLE. This will usually not be much of a
problem, because before schedule() is called, the condition will be
tested again. This condition is probably met because that's what caused
the interrupt anyway. But what if the process get scheduled by the timer
tick or some other interrupt before it could set it's state back to
TASK_RUNNING, we have a serious problem. In that case there is no source
that will wake up this process anymore.
Is this really an issue, or am I missing something,
Thanks,
Mark
-- <<Remove the del for email>>
- Next message: Markus Kossmann: "Re: Silicon image sata controler"
- Previous message: nickel: "Linux driver about a PCI/SCSI device"
- Next in thread: Kasper Dupont: "Re: __wait_event_interruptible question"
- Reply: Kasper Dupont: "Re: __wait_event_interruptible question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|