Re: Re: how to sleep in kernel space ?

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

 



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;
	}
}

And second...let me guess, you put that loop on the procedure assigned 
on module_init(), correct? That's where you stuck...on module 
initialization. because it is executed on behalf of insmod/modprobe, 
you will get perception that insmod/modprobe is stuck.

Solution: put your schedule_timeout() code outside 
module_init/exit....put it e.g inside workqueue. For more about this, 
please read Linux Device Driver 3rd edition (do Googling and grab the 
free PDF) :)

good luck....

regards,


Mulyadi


--
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