What is kthreadd process and children and how it is different from init and children

為{幸葍}努か 提交于 2020-05-09 19:01:08

问题


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 .


回答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".



来源:https://stackoverflow.com/questions/17988526/what-is-kthreadd-process-and-children-and-how-it-is-different-from-init-and-chil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!