LWN.net Logo

Driver porting: wait queue and preemptible code

Driver porting: wait queue and preemptible code

Posted Dec 21, 2003 15:12 UTC (Sun) by nblanc (guest, #17996)
Parent article: Driver porting: sleeping and waking up

With kernel 2.4, you can assume that when you set the process
into TASK_INTERRUPTIBLE mod, there will be no scheduling
(until you decide to do it explicitly).

But what happens with kernel 2.6 in the case below.

for (;;)
{
add_wait_queue(&queue, &wait);
<------------------------------------------ Event occured
set_current_state(TASK_INTERRUPTIBLE);
if (condition) break;
schedule();
remove_wait_queue(&queue, &wait);
if (signal_pending(current))return -ERESTARTSYS;
}
<------------------------------------------- Schedule
set_current_state(TASK_RUNNING);

I think code like the previous one is no more safe with kernel 2.6.
Is it right?

Does the new way to do take care of this?


Nicolas


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds