Re: Threads in 2.6.x kernel

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

 






>>Especialy for modules, you must make sure the thread has exited before
>>you return from module_done(). And there is only one way to do it -- use
>>complete_and_exit() to end the thread and wait_for_completion() in
>>module_dome(). That means, that the thread must exit actively.

>>Now the question comes down to how to tell the thread to exit. There are
>>generaly two ways:
>>1) Have a flag somewhere. Wake up the thread (by setting it's state to
>>   running or using a waitqueue) and have it check that flag and
>>   complete_and_exit() if it's set.
>>2) Use a signal. You can send the thread a signal and it will cause it
>>   to wake up from interruptible sleep automaticaly. But you must check
>>   signal_pending() yourself and complete_and_exit() if appropriate bit
>>   is set. Normaly, signals are handled during return to userspace, but
>>   kernel threads never return to userspace. Thus you have to check for
>>   them manualy.


I have a doubt regarding the usage of complete_and_exit
it makes use of a completion structure.

I am initialising it with
init_completion() at init starting the thread and
Wait_for_completion() at exit module for waiting for the thread
a complete_and_exit() i am using at thread and i get the signal sigterm
using signal_pending,...
But is it not enough to just return a zero from the thread?.Is it just a
synchronisation mechanism like waitqueue??..


Thanks in advance
Regards
Sudharsan




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