On 8/27/06, Dinesh Ahuja <mdlinux7@xxxxxxxxxxx> wrote:
Hi Mulyadi, > set_current_state(TASK_INTERRUPTIBLE); >I think this is the problem. You set a running task >into sleeping state, but didn't quickly follow it with >re-scheduling function (that implicitly use wait queue >too). What happen here was, your kernel thread was >declared in sleeping state, time slice was running >out, your thread was kicked out from CPU but wasn't >runnable anymore. This does not seems to be an issue as this line which I have added to set the state of current process is done in interruptible_sleep_time_out() function. Removing this line does not solve problem and I still get oops.
Hi Dinesh, Can you please post your original code (which OOPs) once again on this mailing list. The code you posted earlier is I think the one which Mulyadi suggested you. Seeing the original code might give us the hint source of OOPs. Just a suggestion, interruptible_sleep_on() is obsolete function as it can cause a race condition. Read the Rubini's LDD for more on it. regards, Gaurav
Internally, interruptible_sleep_time_out() invokes schedule_timeout() {kernel/sched.c}. When I invoke schedule_timeout directly, everything works fine. I donot know what goes wrong when I try to invoke interruptible_sleep_time_out(). Regards Dinesh Actually, you don't need it, because interruptible_sleep_time_out do it all for your. --- Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote: > Hi Dinesh... > > > Sorry for being late in replying back. I have used > > schedule_timeout and it is working fine. But > curious > > to know what wrong is going on while using wait > > queues. > > I am working on kernel 2.4.20 > > Here is full code: > [deleted]... > > set_current_state(TASK_INTERRUPTIBLE); > > I think this is the problem. You set a running task > into sleeping state, > but didn't quickly follow it with re-scheduling > function (that > implicitly use wait queue too). What happen here > was, your kernel > thread was declared in sleeping state, time slice > was running out, your > thread was kicked out from CPU but wasn't runnable > anymore. > > Actually, you don't need it, because > interruptible_sleep_time_out do it > all for your. > > I'll give another example how it is really done if > you want to do it on > very low level way. Take a look on > wait_for_completion(). Comments are > added inline: > void wait_for_completion(struct completion *x) > { > spin_lock_irq(&x->wait.lock); > if (!x->done) { > // [Mulyadi]: declare a wait queue > DECLARE_WAITQUEUE(wait, current); > > wait.flags |= WQ_FLAG_EXCLUSIVE; > // [Mulyadi]: add to the wait queue first > __add_wait_queue_tail(&x->wait, > &wait); > do { > // [Mulyadi]: and then mark the current task as > interruptible > > __set_current_state(TASK_UNINTERRUPTIBLE); > > spin_unlock_irq(&x->wait.lock); > // [Mulyadi]: feel free to reschedule > schedule(); > > spin_lock_irq(&x->wait.lock); > } while (!x->done); > // [Mulyadi]: if you are done with it, remove the > task from wait queue > __remove_wait_queue(&x->wait, > &wait); > } > x->done--; > spin_unlock_irq(&x->wait.lock); > } > > That way, the kernel knows that you're asking to be > woken up when a > signal is delivered, an event happens or simply > because of timeout. > > So the conclusion is, as far as I know, declare a > waitqueue, insert the > task to waitqueue, and set the task state. Don't > mess this order... > > regards, > > Mulyadi > > __________________________________________________________ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
-- Gaurav Email: gauravd.chd@xxxxxxxxx -------------------------------------------- Read my articles at: http://lkdp.blogspot.com -------------------------------------------- Easy to get air tickets at affordable price, US to India Air Tickets: www.Ritz-Travel.com Call at 001-503-848-2299 or mail at info@xxxxxxxxxxxxxxx -------------------------------------------- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/