Search code examples
linuxprocfssar

How is run queue length computed in linux proc filesystem


I'm trying to obtain number of runnable processes from linux kernel. sar -q gives this information readily. However I'm trying to get this value from /proc filesystem. There is no file in /proc that gives this value directly, then how is runq-sz computed. The wiki page http://en.wikipedia.org/wiki/Load_(computing) provides some insight into how run queue length is computed based on ldavg values but it is unclear. Can someone provide more pointers on this. Cheers


Solution

  • As gcla said you cat use

    cat /proc/loadavg
    

    to read loadavarage from from kernel - but strictly speaking, it is not a queue length.

    Take a look at

    grep procs_running /proc/stat
    

    and

    grep procs_blocked /proc/stat
    

    First is an actual running queue and second is a number of process blocked on disk IO. Load average is a function from sum of both.