I wanted to know what is kthread
and why it does not take any memory and has no open files. I wrote some code which will simply print the PID of the currently running processes in a parent child tree format along with some additional information like used VMZ, RSS, threads, openfiles. All the children of the PID 2 named kthreadd
did not have the VmSize and VmRSS in the /proc/[pid]/status
file. the /proc/[pid]/fd
did not contain any open files.
What are these processes, how they are different with normal processes spawned by init (PID 1). I read (in an old book) that the swapper will spawn init PID1 and all other process are children of PID 1. Definitely there is a different architecture behind this (Linux kernel 3.7.10.1-16) which I don't know, so another question is why PID 2 is a child of PID 0 and is not a child of PID 1 .
Kernel threads are not children of init because they can be started before all the userspace processes.
They are typically used to manage hardware that's why they are directly handled by the kernel and have high priority.
For a process to be child of init it needs to be cloned from init and Kthreads aren't that's why their parent PID is 0 meaning "no-one".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With