如何编程获得系统休眠的任务数?

zhqyzhqychn 2010-06-18 07:50:38
正在运行的数可以在/proc/stat里获得,休眠的感觉也应该在/proc 文件系统里,但不知道在哪个文件里获得,求教
...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhqyzhqychn 2010-06-19
  • 打赏
  • 举报
回复
谢谢,
brookmill 2010-06-18
  • 打赏
  • 举报
回复
不知道怎么编程获得。我知道的有关的命令:

1.
top输出的第二行 Tasks: 166 total, 1 running, 165 sleeping, 0 stopped, 0 zombie

2.
ps -Al的第二列
$ man ps
......
PROCESS STATE CODES
Here are the different values that the s, stat and state output
specifiers (header "STAT" or "S") will display to describe the state of
a process.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being
traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its
parent.

3.
$ man proc
......
/proc/[pid]/stat
Status information about the process. This is used by ps(1).
It is defined in /usr/src/linux/fs/proc/array.c.

The fields, in order, with their proper scanf(3) format speci-
fiers, are:

pid %d The process ID.

comm %s The filename of the executable, in parentheses.
This is visible whether or not the executable is
swapped out.

state %c One character from the string "RSDZTW" where R is
running, S is sleeping in an interruptible wait, D
is waiting in uninterruptible disk sleep, Z is zom-
bie, T is traced or stopped (on a signal), and W is
paging.

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧