Re: /proc/pids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jakko


> Well you gave me the general code of the proc filesystem;
> alas, I want to know where is the code that _uses_ the proc code
> in order to export proc directories of the process ids of the system
> (i.w. /proc/1/, /proc/2/, ...)

try to check proc_pid_readdir() in fs/proc/base.c. It will give you the 
idea how thos /proc/<pid>s are created. Short story, I got impression 
they are created on the fly (i.e when you read them), not when a 
process is created. Same thing with destruction.

The trick is faking file read offset as pid selector, and from there, 
task's properties are fetched and showed as subdirectory under 
/proc/<pid>/ . Sounds like expensive operation? Yes it is, but IIRC 
dcache and icache will make the subsequent operation faster. However, 
the contents are volatile since they represent the current task's 
status. Realizing these, you will find out why sometimes using "top" 
with small update frequency is not preferred :) It traverses 
/proc/<pid>/ again and again, reopening file descriptors instead of 
creating and hold them as long as it can

regards,

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux