Solaris CPU 运行队列

发布于 2024-08-20 23:00:38 字数 72 浏览 10 评论 0原文

有没有命令可以告诉我 Solaris 运行队列中有什么? 我可以使用 vmstat 获得计数,但我需要知道其中有哪些进程/线程。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不打扰别人 2024-08-27 23:00:38

运行队列总是在变化,因此几乎不可能获取当前运行队列中的进程集。

也就是说,您可以通过查看 ps 中进程列表的 STAT(状态)字段来获得近似值。运行以下命令时:

$ ps aux

...如果 STAT 字段以 R 开头,则该进程被内核标记为 RUNNABLE,这在大多数操作系统上意味着它在运行队列中。以下是可运行进程在我的机器上的样子:

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

在Solaris 上,您还可以使用prstat 命令并查看STATE 列。值run 表示该进程位于运行队列中。 (另请注意,值 cpuN 表示该进程当前正在处理器 N 上运行。

例如:

$ 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

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
蓝咒 2024-08-27 23:00:38

当我看到你已经这样做时,我正要纠正 0xfe 答案。运行队列包含不进程的ads,因此如果您希望“状态运行”行的数量或多或少与运行队列匹配,则 prstat 命令必须使用 -L 选项。请注意,采样工件可能会妨碍获得准确的匹配。

无论如何,如果您想准确地知道运行队列中有哪些进程/线程,您宁愿采用 dtrace 方式(假设您运行的是 Solaris 10 或更高版本)。

whoqueue.d 脚本可能已经位于您计算机上的 /usr/demo/dtrace 目录中,这将是一个好的开始:

# dtrace -s /usr/demo/dtrace/whoqueue.d
Run queue of length 1:
  24349/1 (dtrace)
Run queue of length 3:
  0/0 (sched)
  0/0 (sched)
  0/0 (sched)
Run queue of length 4:
  22468/30 (java)
  22468/17 (java)
  22468/23 (java)
  22468/10 (java)

查看 此页面了解详细信息。

I was about to correct 0xfe answer when I saw you already did it. The run queue is containing theads not processes so the -L option is mandatory with the prstat command if you want to have the number of "state run" lines more or less matching the run queue. Beware that sampling artifacts will probably prevent to get accurate matches.

In any case, if you want to precisely know what processes/threads are sitting in the run queue you'd rather go the dtrace way assuming you are running Solaris 10 or newer.

The whoqueue.d script which might already been in /usr/demo/dtrace directory on your machine will be a good start:

# dtrace -s /usr/demo/dtrace/whoqueue.d
Run queue of length 1:
  24349/1 (dtrace)
Run queue of length 3:
  0/0 (sched)
  0/0 (sched)
  0/0 (sched)
Run queue of length 4:
  22468/30 (java)
  22468/17 (java)
  22468/23 (java)
  22468/10 (java)

Have a look at this page for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文