Check if the process in in RUNNING state or RUNNABLE state in Linux

399 Views Asked by At

The state of any process can be found out by using multiple tools including reading from /proc/[pid]/status where

$ cat /proc/8976/status
Name:   redis-server
State:  R (Running)
Tgid:   8976
Pid:    8976
PPid:   8964
...

The R here typically denotes that the process is either in running or runnable state. Can we somehow check using the existing /proc or sysfs or existing kernel tooling if the process is waiting to be scheduled upon the CPU in a runqueue or if the process is indeed running on the CPU?

I do understand that since Linux is preemptive, it can preempt after a time slice and maintain fairness amongst the processes which should not result in high runqueue latencies.

0

There are 0 best solutions below