How does top get the shared memory of a process in linux?

I just looked it up briefly, and I think I got it from some files under the / proc directory. I"ve seen that the most possible / proc/pid/status file doesn"t have shared memory, so I guess it was obtained through some kind of calculation, asking for advice.

clipboard.png

Mar.04,2021

read from the proc/ file, you can also write a tool to read.
the / proc file system is a very important file system in linux. You can get almost all the running information from him.


answer it yourself. After checking the source code of top, it is found that it is / proc/pid/statm file

.
Menu