什么是kthreadd进程和子进程,它与init和子进程有何不同 [英] What is kthreadd process and children and how it is different from init and children

查看:802
本文介绍了什么是kthreadd进程和子进程,它与init和子进程有何不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是kthread,为什么它不占用任何内存并且没有打开的文件.我写了一些代码,它们将以父子树格式简单地打印当前正在运行的进程的PID,以及一些其他信息,例如使用的VMZ,RSS,线程,openfiles. PID 2的所有子元素kthreadd/proc/[pid]/status文件中都没有VmSize和VmRSS. /proc/[pid]/fd没有包含任何打开的文件.

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.

这些进程是什么,它们与init(PID 1)生成的普通进程有何不同.我读(在一本旧书中),交换器将生成init PID1,所有其他进程都是PID 1的子级.在此背后肯定有一个不同的体系结构(Linux内核3.7.10.1-16),我不知道,因此另一个问题是为什么PID 2是PID 0的子代而不是PID 1的子代.

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 .

推荐答案

内核线程不是init的子代,因为它们可以在所有用户空间进程之前启动.

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.

要使一个进程成为init的子进程,需要将其从init中克隆出来,而Kthreads不是,这就是其父PID为0表示无"的原因.

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

这篇关于什么是kthreadd进程和子进程,它与init和子进程有何不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆