Re: Re: how to sleep in kernel space ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/5/05, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
> Dear Sabarinathan...
> 
> First of all, please CC your reply to the mailing list, so others might
> give better hints and our overall discussion can be archieved :)
> 
> > when i am using schedule_timeout (1000), say in (Kernel Module)
> > while (1)
> > {
> > /* my code here */
> > schedule_timeout (1000) ;
> > }
> > I am unable to quit the while loop (say after everything is over)
> > when i press ctrl + C i am unable to come out of it and it hangs so i
> 
> Of course you can get out of the loop,  you are doing endless while
> loop, remember? :) You need to use somekind of flag variable to get out
> from the loop.
> 
> while (your_condition=1)
> {
>         schedule_timeout(1000);
>         if_you_have_reach_certain_condition {
>                 your_condition=0;
>         }
> }

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.

Thanks,
Nish

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux