LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 10-13-2005, 10:58 PM   #1
oriate
Member
 
Registered: May 2005
Posts: 33

Rep: Reputation: 15
kernel thread and signal handling


How does kernel thread handle signals? Or will they handle signals?
I mean "kernel thread",not "user thread".
 
Old 10-14-2005, 10:25 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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.
 
Old 10-14-2005, 10:37 PM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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.
 
Old 10-18-2005, 12:41 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 11,370
Blog Entries: 4

Rep: Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178
"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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Threads in signal handling shilpig Programming 3 08-20-2009 03:14 AM
Signal handling......... rajsun Programming 2 06-28-2005 08:10 AM
Signal handling in threads in 2.6 vs. 2.4 kernel dlocke Linux - Software 0 09-29-2004 06:11 PM
Signal Handling with LinuxThrreads TedMaul Programming 1 05-01-2004 01:56 PM
Signal handling Mohsen Programming 2 07-30-2003 06:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration