需要top的源码并找到top与linux中/proc/目录的联系
我想要 top 的源代码,但我在任何地方都找不到,我想要更多关于 /proc 目录到底包含什么的信息。我看到它有一系列标记为 1、2、3 4、.. 的文件夹。 ..并且在这些文件夹中似乎有一组一致的文件。我想知道这些是否是当前机器上运行的进程的目录。
我还想知道 TOP 到底是如何链接到这个文件夹的,因为我被告知进程是由 TOP 通过从这些目录中获取数据来监控的。我想知道哪个文件到底是从目录中获取特定进程的 CPU 使用率的 TOP 文件。如果它太复杂,如果您能指出我可以真正理解这一点的代码部分,那就太好了!
感谢您的帮助 舒维克
I wanted the source code for top which I could not find anywhere also, i wanted a little more information on what exactly does the /proc directory contain.y I have seen it have a series folders labeled 1, 2, 3 4, .... and in those folders there seem to be a consistent set of files. I was wondering if these are the directories for the processes running on the machine at the moment.
Also I wanted to know, how exactly TOP linked to this folder because I have been told that the processes are monitored by TOP, by fetching data from these directories. I would like to know which file exactly is TOP getting the CPU usage of the particular process from with the directory. If it's too complicated it would be great if you could just point me to the portion of the code where I could actually understand this from!
Thanks for your help
Shouvik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实用程序
信息伪文件系统
utilities
information pseudo-filesystem
procfs 基本上是系统和进程信息的文件抽象。
编号的文件夹当前正在运行具有与文件夹名称相关的 PID 的进程。
跟踪 top 或任何其他进程读取了哪些文件
您可以使用树莓派
或更一般的 grep 来
,例如,U 获取输出
在这里您可以看到,top 打开了文件
其中包含有关进程的某些信息
The procfs is basically an file abstraction of system and process information.
The numbered folders are currently running processes with the folder name related PID.
You can trace which files where read out by top or any other process with
or on raspberry
or more general with grep
for example, U get the ouput
Here you can see, that top opened the file
which contains certain information about the process
top 是 procps 的一部分,是的,这些数字是进程 ID。
top is part of procps, and yes, those numbers are process id's.