On 9/5/05, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote: > Hello Nish :) > > > Both of your code snippets are broken. You *must* set the state > > before calling schedule_timeout() to either TASK_INTERRUPTIBLE or > > TASK_UNINTERRUPTIBLE. If you don't, then you will have a busy loop. > > If you use INTERRUPTIBLE, signals will kill the sleep, in > > UNINTERRUPTIBLE, they will not. > > Damn, I forgot that, thanks for reminding me about it, Nish. So, yes, > use set_current_state(TASK_INTERRUPTIBLE) or > set_current_state(TASK_UNINTERRUPTIBLE) before you call > schedule_timeout. Yes, quite easy to forget, too, so akpm has accepted a number of patches from me to add schedule_timeout_interruptible() and schedule_timeout_uninterruptible() functions to the -mm tree. > However, you still need a way to get out from that "while" loop, so > checking for certain condition(s) are still necessary, unless you don't > mind with rude "kill" :) Indeed. Although, if you are waiting for an event to occur, simply sleeping inbetween, you may be best served by a wait-queue and wait_event(). Thanks, Nish -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/