如何获取CPU等待队列中的线程数?

如何获取CPU等待队列中的线程数?

有没有办法以编程方式获取 Linux 上等待 cpu 的线程数。

答案1

从 ps 手册页中,状态字段将告诉您线程是否在运行队列上(使用“L”选项查看线程)--

  D    uninterruptible sleep (usually IO)
  R    running or runnable (on run queue)
  S    interruptible sleep (waiting for an event to complete)
  T    stopped by job control signal
  t    stopped by debugger during the tracing
  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

相关内容