Search code examples
solariscpu-usage

Solaris CPU run queue


Is there a command which can tell me whats in the Solaris run queue? I can get a count using vmstat, but I need to know what processes/threads are in there.


Solution

  • The run-queue is always changing, so it's almost impossible to get the set of processes in the current run-queue.

    That said, you can get an approximation by looking at the STAT (state) field of the process list from ps. When running the command below:

    $ ps aux
    

    ...the if the STAT field begins with R, then the process is marked RUNNABLE by the kernel, which on most operating systems means that it is in the run-queue. Here's what a runnable process looks like on my machine:

    USER       PID %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
    root     78179   0.0  0.0   599828    480 s003  R+    7:51AM   0:00.00 ps aux
    

    On solaris, you can also use the prstat command and look at the STATE column. The value run indicates that the process is on the run-queue. (Also note that the value cpuN indicates that the process is currently running on processor N.

    For example:

    $ prstat -s cpu -n 5
    
    PID USERNAME    SIZE    RSS STATE   PRI NICE    TIME    CPU PROCESS/NLWP
    13974   kincaid 888K    432K    run 40  0   36:14.51    67% cpuhog/1
    27354   kincaid 2216K   1928K   run 31  0   314:48.51   27% server/5
    14690   root    136M    46M sleep   59  0   0:00.59 2.3%    Xsun/1
    14797   kincaid 9192K   7496K   sleep   59  0   0:00.10 0.9%    dtwm/8
    14851   kincaid 24M 14M sleep   48  0   0:00.03 0.3%    netscape/1
    Total: 97 processes, 190 lwps, load averages: 2.18, 2.15, 2.11