* sleep for ever ? [not found] <44FED70F.6080208@mail.nankai.edu.cn> @ 2006-09-06 14:11 ` Bo Yang 2006-09-07 10:01 ` Tejun Heo 0 siblings, 1 reply; 4+ messages in thread From: Bo Yang @ 2006-09-06 14:11 UTC (permalink / raw) To: linux-kernel Hi , Take a look at following code : DECLARE_WAITQUEUE(wait, current); add_wait_queue(q, &wait); while (!condition) { /* if there is an interrupt here , and the interrupt is just the one the sleeping process wait for , is this process sleep for the interrupt for ever ?*/ set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current)) /* handle signal */ schedule(); } set_current_state(TASK_RUNNING); remove_wait_queue(q, &wait); Suppose the process just want to sleep for an hardware event , but before the set_current_state() call , the event come , is the process sleep for ever ? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sleep for ever ? 2006-09-06 14:11 ` sleep for ever ? Bo Yang @ 2006-09-07 10:01 ` Tejun Heo 0 siblings, 0 replies; 4+ messages in thread From: Tejun Heo @ 2006-09-07 10:01 UTC (permalink / raw) To: Bo Yang; +Cc: linux-kernel Hello, there. Bo Yang wrote: > Hi , > Take a look at following code : > > DECLARE_WAITQUEUE(wait, current); > > add_wait_queue(q, &wait); > while (!condition) { > /* if there is an interrupt here , and the interrupt > is just the one the sleeping process wait > for , is this process sleep for the interrupt > for ever ?*/ > set_current_state(TASK_INTERRUPTIBLE); > if (signal_pending(current)) > /* handle signal */ > schedule(); > } > set_current_state(TASK_RUNNING); > remove_wait_queue(q, &wait); > > Suppose the process just want to sleep for an hardware > event , but before the set_current_state() call , the event > come , is the process sleep for ever ? I guess you already know it but please try not to post the same message multiple times. And, yes, you're responsible to set task state *before* testing for the sleeping condition and sleep. In the above code, you can lose the wake up event and thus sleep indefinitely. -- tejun ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <44FED695.9030501@mail.nankai.edu.cn>]
* sleep for ever ? [not found] <44FED695.9030501@mail.nankai.edu.cn> @ 2006-09-06 14:09 ` 杨波 0 siblings, 0 replies; 4+ messages in thread From: 杨波 @ 2006-09-06 14:09 UTC (permalink / raw) To: linux-kernel Hi , Take a look at following code : DECLARE_WAITQUEUE(wait, current); add_wait_queue(q, &wait); while (!condition) { /* if there is an interrupt here , and the interrupt is just the one the sleeping process wait for , is this process sleep for the interrupt for ever ?*/ set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current)) /* handle signal */ schedule(); } set_current_state(TASK_RUNNING); remove_wait_queue(q, &wait); Suppose the process just want to sleep for an hardware event , but before the set_current_state() call , the event come , is the process sleep for ever ? ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <44FED63F.2090204@mail.nankai.edu.cn>]
* sleep for ever ? [not found] <44FED63F.2090204@mail.nankai.edu.cn> @ 2006-09-06 14:07 ` 杨波 0 siblings, 0 replies; 4+ messages in thread From: 杨波 @ 2006-09-06 14:07 UTC (permalink / raw) To: linux-kernel Hi , Take a look at following code : DECLARE_WAITQUEUE(wait, current); add_wait_queue(q, &wait); while (!condition) { /* if there is an interrupt here , and the interrupt is just the one the sleeping process wait for , is this process sleep for the interrupt for ever ?*/ set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current)) /* handle signal */ schedule(); } set_current_state(TASK_RUNNING); remove_wait_queue(q, &wait); Suppose the process just want to sleep for an hardware event , but before the set_current_state() call , the event come , is the process sleep for ever ? ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-07 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <44FED70F.6080208@mail.nankai.edu.cn>
2006-09-06 14:11 ` sleep for ever ? Bo Yang
2006-09-07 10:01 ` Tejun Heo
[not found] <44FED695.9030501@mail.nankai.edu.cn>
2006-09-06 14:09 ` 杨波
[not found] <44FED63F.2090204@mail.nankai.edu.cn>
2006-09-06 14:07 ` 杨波
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox