Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-13-2005, 10:58 PM
|
#1
|
Member
Registered: May 2005
Posts: 33
Rep:
|
kernel thread and signal handling
How does kernel thread handle signals? Or will they handle signals?
I mean "kernel thread",not "user thread".
|
|
|
10-14-2005, 10:25 PM
|
#2
|
Senior Member
Registered: Jun 2004
Posts: 2,553
Rep:
|
this is one of those things i imagine you will find lots of argument about and i'm really not sure, exactly sure, whats happening in the kernel right now.
kernel thread signals are generally considered a horrible evil and signals are for user space.
rant and rave, rant and rave.
seems like there is a function to set allow_signal() that only allows
SIGKILL otherwise signals are silently dropped. At least that's how it was the last time i looked.
|
|
|
10-14-2005, 10:37 PM
|
#3
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
|
The kernel doesn't "handle" signals per se, other than posting them to userland processes. That being said, there are kernel space processes such as nfsd that need to be able (I assume) to receive signals to shut down, and I'm not totally sure how that works. Kernel threads do have the same sort of process info structure associated with them as userspace programs, IIRC, they just are totally memory mapped into kernel space. So I imagine they can access their own signal table and set up "handlers" within the kernel. This is more my intuition based on my understanding of how the kernel works rather than something I've actually researched, so I may be wrong on this.
Note that things are different in kernel mode. If you have an unrecoverable page fault in the kernel, you generally crash the system.
|
|
|
10-18-2005, 12:41 PM
|
#4
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 11,370
|
"Use the Source, Luke!"
A good example of a kernel thread that does more-than-trivial things is found in fs/lockd/svc.c.
This is a "lock management daemon" that interacts with user-land processes in interesting ways and thus should serve as an interesting example.
Other daemons, like the swap-daemon in mm/vmscan.c, are pretty much self-contained, interacting only with the kernel and basically serving as a vehicle for doing I/O.
The fundamental reason for kernel-threads, and for mechanisms like "keventd" (kernel/context.c), is to be able to do things asynchronously in a kernel-context. You see, if you think about it, in many ways the kernel is just a great big subroutine-library, called to do various things which it does in the context of whatever process called them. But some things that it has to do are asynchronous in nature, not linked closely to any particular user-land process, and ... how do you handle these things, and (we would like) handle them elegantly? The concept of having a "dispatchable, schedulable, basically-autonomous thing" that is nonetheless "fully part of the kernel" is a way of doing that.
|
|
|
All times are GMT -5. The time now is 09:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|