Kernel threads

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

 



Hello everyone,

Does anyone here know of any good documentation on creating daemon
processes as kernel threads. More specifically, I have some information
on the mechanics of kernel thread creation (examples in the Linux source
code, a cached copy of www.scs.ch/~frey/linux/kernelthreads.html from
Google), and now I'm more concerned with the reasoning behind some of
the operations, potential pitfalls to watch out for, and so on.

So far in my study of the kernel sources, I have found that the general
procedure seems to be: 
- call kernel_thread() on the function written to be the daemon process 
- daemonize() (or a similar set of instructions to detach from
user-space resources)
- set up the signal mask
- enter into an endless loop

However, I've noticed some minor differences in the way some of the
kernel threads are started:
- Some threads (ie, kjournald, nfsd) grab the big kernel lock, and some
don't (keventd, kswapd, bdflush). Under what conditions, if any, would
this be necessary? What resources is this lock trying to protect?
- Sometimes (quite often, actually) the caller of kernel_thread() blocks
on some kind of wait queue or semaphore, and the kernel thread wakes it
up after some amount of processing (usually before the endless loop in
my general procedure above). Why is this done, and what could happen if
the caller was just allowed to continue on after calling
kernel_thread()?

If anyone can direct me to any documentation that addresses these
issues, I would be grateful. Or if anyone can answer some of the
questions above, that would be great, too. Thanks in advance.

-- 
Trevor Hamm

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