[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sleep process, wait queues
On Sun, Jul 03, 2005 at 11:58:54AM +0100, Deepak Joshi wrote:
>
> --- Deepak Joshi <deepak_cins@xxxxxxxxxxx> wrote:
>
> > #include <linux/module.h>
> > #include <linux/kernel.h>
> > #include <linux/wait.h>
> > #include <linux/sched.h>
> > #include <linux/list.h>
> > MODULE_LICENSE("GPL");
> >
> >
> >
> > static DECLARE_WAIT_QUEUE_HEAD (my_queue);
> > int init_module(void)
> > {
> > struct task_struct *my_task ;
> > my_task = find_task_by_pid(1477);
> > DECLARE_WAITQUEUE(wait, my_task);
> > my_task->state = TASK_UNINTERRUPTIBLE ;
> > init_waitqueue_entry( &wait, my_task);
> > add_wait_queue( &my_queue , &wait);
> > sleep_on(&my_queue);
> > interruptible_sleep_on(&my_queue);
> > schedule( );
the last 3 calls all operate on the current process, not my_task (read
the sources). Also, you are sleeping twice here and only waking up once
below.
> > return 0;
> > }
> >
> >
> > void cleanuo_module()
> > {
> > printk("Bye");
> > wake_up( &my_queue );
> > }
AFAICT what you are trying to do is not really possible using
waitqueues, try to look at kernel/signal.c and SIGSTOP and SIGCONT
instead.
bye
--
mattia
:wq!
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/