What is kthreadd process and children and how it is different from init and children
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".
Related videos on Youtube
Comments
-
phoxis over 4 years
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 namedkthreadd
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 .
-
Rex almost 11 yearsI think this may help you.... unix.stackexchange.com/questions/13290/…
-
phoxis almost 11 yearsThis answer in unix.stackexchange Does not answer in detail. I require more detailed information.
-
-
phoxis over 10 yearsThanks for the answer, but can you give me some reference to some documentation?
-
Lucas Werkmeister almost 6 years“All userspace processes have typically a PID superior to 1000, only kernel threads are allowed to have PID inferior to 1000.” – this part is definitely false, or at least it is today: I’m looking at a PID874
upowerd
, PID747accounts-daemon
, PID719gdm
over here. I suspect it’s pre-systemd folklore, from when the init process involved lots of shell scripts, which would consume PIDs < 1000 so you would be unlikely to see them under regular operation (until the PID space wrapped around, of course).