Re: Introduction to kernel threads

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

 



Hi Kristian...

Nice to read your message....

On Fri, Nov 27, 2009 at 10:29 PM, Kristian Evensen
<kristian.evensen@xxxxxxxxx> wrote:
> I am working on a module that communicates with userspace using Netlink in a
> separate thread. The way I have designed the module I want to use a blocking
> call (skb_recv_datagram) to receive the packets. The problem comes when I
> want to kill this thread. Currently, I signal it using send_sig, but
> compared to the kthread_*-functions this seems a bit "dirty".
>
> My questions are:
>
> - Is it ok to kill a thread using signals?

to the best I know, you can send signal to a kernel thread, however
that won't kill it. SIGKILL handler, like any other default signal
handler, is only invoked when a process return to user space.

Thus in this case, the thing you can do is check whether there is
signal queued for your kernel thread. If there is...and let's say it's
SIGKILL, then stop your kernel thread (gracefully).

> - After reading up on kthread_stop, I now see that it does not send a
> signal. Are there any other kthread_* or similar functions which does this,
> or will at least unblock the thread?

More or less same, kthread_stop is just toggling a flag on. This flag
should be checked by the related kernel thread function, and if it is
true, then stop the kernel thread.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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