2

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.

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
user2512324
  • 791
  • 1
  • 6
  • 21
  • I remember when you couldn't do that because the process that was running rather than runnable was the process checking. – Joshua Jun 01 '21 at 02:33
  • Thanks. Can you refer to the source for understanding it more. – user2512324 Jun 02 '21 at 04:17
  • 1
    At one time the number of CPUs that Linux knew how to use was one. https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz I wish I could answer your question though because with more than one processor, there really could be another running process. – Joshua Jun 02 '21 at 04:26

0 Answers0