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