lkml.org 
[lkml]   [1999]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Problems writting a CHAR Driver with interruptible_sleep (wait_queu e)
On Sat, 14 Aug 1999, Russell King wrote:

> Benjamin LaHaise writes:
> > current->state = TASK_INTERRUPTIBLE;
> > add_wait_queue(&my_wait_queue, &wait);
>
> That should be:
> add_wait_queue(&my_wait_queue, &wait);
> current->state = TASK_INTERRUPTIBLE;
>
> otherwise there is a chance that the interrupt could occur between
> the TASK_INTERRUPTIBLE and the add_wait_queue. If this does happen,
> the task will not be on my_wait_queue, and therefore the state will
> not be set to TASK_RUNNING.

Ummm, no, that's worse and a different kind of race: you'll note that in
the original code I posted, the trigger for the wake up should be
started *after* the add_wait_queue. With your change, what happens if
someone else had already triggered the interrupt and it does a wake_up
between the add_wait_queue and current->state = TASK_INTERRUPTIBLE? The
task will then sleep until the wait queue gets another
wake_up_interruptible or a signal arrives for the task, which is wrong.

-ben


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:2.737 / U:2.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site