https://access.redhat.com/solutions/1545943
How to check Running and Runnable processes ?
SOLUTION 已验证 - 已更新 2015年九月10日17:24 -
环境
- Red Hat Enterprise Linux 6
问题
- What is Running and Runnable processes?
- How to identify Running and Runnable processes?
决议
-
Command : # ps -er
Both Running and Runnable state of process shows as 'R' in ps commands output. They have ps-state as TASK_RUNNING.
The TASK_RUNNING state means that the process is runnable, and it is either currently running or on a runqueue waiting to run. This is the only possible state for a process executing in user space (i.e., that portion of system memory in which user processes run); it can also apply to a process in kernel space (i.e., that portion of memory in which the kernel executes and provides its services) that is actively running.
A runqueue is the basic data structure in the scheduler, and it contains the list of runnable processes for the CPU, or for one CPU on a multiprocessor system. The scheduler, also called the process scheduler, is a part of the kernel that allocates the scare CPU time among the various runnable processes on the system.
-
To identify only running processes use : # ps auxr
The “r” option restrict the selection to only running processes.
-
The tools such as vmstat and sar -q can be used to see the runnable processes.
As per RHEL 6 environment, vmstat shows the runnable processes
# vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 8226336 326316 5656572 0 0 3 26 61 8 3 1 96 0 0
Here, “r” represents the runnable process.
# sar -q
In sar -q, runq-sz parameter shows the number of kernel threads in memory that are waiting for a CPU to run. This means the number of runnable processes. But, there is timestamp issue here, as it is displayed every 10 minutes. The processes which are in runnable queue between 10 minutes are not captured.
-
To know exactly which processes are running and which are waiting in runnable queue, we may get from crash prompt.
-
Configure kdump on your system : How to configure Kdump?
-
Install the kernel-devel package (kernel-devel version must be in sync with your kernel)
-
Install the crash utility
-
Fire runq command.
Output of runq command: CPU 0 RUNQUEUE: ffff8800366168c0 CURRENT: PID: 0 TASK: ffffffff81a8d020 COMMAND: "swapper" <==== current running process RT PRIO_ARRAY: ffff880036616a48 [no tasks queued] CFS RB_ROOT: ffff880036616958 [120] PID: 862 TASK: ffff8808767fa080 COMMAND: "splunkd" CPU 1 RUNQUEUE: ffff8800366568c0 CURRENT: PID: 864 TASK: ffff88061bd95540 COMMAND: "splunkd" <==== current running process RT PRIO_ARRAY: ffff880036656a48 [no tasks queued] CFS RB_ROOT: ffff880036656958 [no tasks queued] CPU 2 RUNQUEUE: ffff8800366968c0 CURRENT: PID: 0 TASK: ffff88047a2bc040 COMMAND: "swapper" <==== current running process RT PRIO_ARRAY: ffff880036696a48 [no tasks queued] CFS RB_ROOT: ffff880036696958 [no tasks queued] CPU 3 RUNQUEUE: ffff8800366d68c0 CURRENT: PID: 2827 TASK: ffff88087676c040 COMMAND: "kondemand/3" <==== current running process RT PRIO_ARRAY: ffff8800366d6a48 [no tasks queued] CFS RB_ROOT: ffff8800366d6958 [no tasks queued] CPU 4 RUNQUEUE: ffff8800367168c0 CURRENT: PID: 0 TASK: ffff88047a313500 COMMAND: "swapper" <==== current running process RT PRIO_ARRAY: ffff880036716a48 [no tasks queued] CFS RB_ROOT: ffff880036716958 [no tasks queued] CPU 5 RUNQUEUE: ffff8800367568c0 CURRENT: PID: 30605 TASK: ffff8804385c0ae0 COMMAND: "cdp-2-6" <==== current running process RT PRIO_ARRAY: ffff880036756a48 [ 0] PID: 23 TASK: ffff88047a312040 COMMAND: "migration/5" <==== runnable process [ 0] PID: 26 TASK: ffff88047a34b500 COMMAND: "watchdog/5" CFS RB_ROOT: ffff880036756958 [120] PID: 2829 TASK: ffff8808764bb540 COMMAND: "kondemand/5
-