Why proc process faster than others?

Deadly 提交于 2019-12-10 12:27:38

问题


As we know there is some process which is faster than other. But I always wonder Why proc process faster than others?


回答1:


Confusion. The /proc/ file system (read proc(5)) is indeed a pseudo-file system without real files on any hard disk. So reading it is quick (and could be faster than reading a file on a spinning hard disk). For example you could write some C code fopen-ing /proc/self/maps, looping on every line using fgets, and showing that line on your stdout, and finally fcloseing it. See this.

On Linux /proc/ is a convenient way to query the kernel about the operating system's state. You generally read (not write) pseudo-files from it.

Try also cat /proc/$$/status and cat /proc/self/maps in some terminal, and think a bit to understand the output.

BTW, if you want to do quickly some IO on files of reasonable size, put them on some tmpfs filesystem (which would be lost at shutdown time, and has some limitations).



来源:https://stackoverflow.com/questions/47069729/why-proc-process-faster-than-others

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