daemonize() function is generally used to convert ordinary processes
into kernel threads - like kswapd, ksoftirqd etc - which do not have
an associated user-space (mm_struct). These kernel threads execute
completely in kernel-space. For processes like this check out the
/proc/<pid>/maps file - it will be empty - since they have no
associated mm_struct.
The daemonize() function reduces the reference count of the struct_mm
structure by calling exit_mm().
Note: kswapd, ksoftirqd etc are especially coded for such a switch
into the kernel, do NOT assume that an ordinary process can be
converted into a kernel thread by calling the daemonize() through a
system call or whatever.
An interesting fact about kernel threads is that since, they do NOT
have access to user space, they dont need the user space page-tables.
So, during a process switch, the TLB (Translation Lookaside Buffer) of
the previous process is not flushed (flushing is a costly operation).
This concept is called Lazy TLB Flushing.
Post by NAHieuHello,
Anybody here could tell me what is the purpose of daemonize() function
in kernel? In wich case should we use it?
Thank you,
NAH
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
The difference between Theory and Practice is more so in Practice than
in Theory.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/