Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Arrow proc file system.

    and i recently studied some system analysis tools, such as top and "SYSSTAT" tool set.

    i found the main things these things do are open and read files in /proc folder, and grab some numerical data and manipulate them.

    so here comes a question, how those files in /proc folder are generated?

    i just want to know which files of kernel actually generate files such as /proc/cpuinfo and /proc/meminfo for instance.

    i try to go through some kernel code. which located around


    i believe it is where proc file system are generated. but i did not see any cpuinfo.c or meminfo.c

    as per say. each file in proc "ties a function which generates the content of the file on fly". so where can i find this "function" for... such as ... cpuinfo and meminfo

    please give guidance for this.

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Take a look through linux-2.6.X/fs/proc/proc_misc.c

    Here you can find routines to create those files and parameters that hold memory related values.
    Registered Linux User #440311

  3. #3
    i have go thru the code roughtly
    i notice for function meminfo_read_proc

    it creates a "struct sysinfo i"
    and i check the sysinfo struct

    it is something like

    struct sysinfo {
    long uptime; /* Seconds since boot */
    unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
    unsigned long totalram; /* Total usable main memory size */
    unsigned long freeram; /* Available memory size */
    unsigned long sharedram; /* Amount of shared memory */
    unsigned long bufferram; /* Memory used by buffers */
    unsigned long totalswap; /* Total swap space size */
    unsigned long freeswap; /* swap space still available */
    unsigned short procs; /* Number of current processes */
    char _f[22]; /* Pads structure to 64 bytes */

    so for more detail,

    actually i want to know how linux kernel get information on memory and cpu.

    any more info on that?

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts