1

As per procfs man

 /proc/[pid]/stat
 (39) processor  %d  (since Linux 2.2.8)
                        CPU number last executed on.

I can see, there is -1 value for some tasks

$ cat /proc/1185/task/1283/stat | awk '{print $39}'
-1

or

$ cat /proc/1283/stat | awk '{print $39}'
-1

Top shows 3 for this thread. (in thread mode and selecting P = Last Used Cpu (SMP) field)

What does this -1 signifies, which processor number it corresponds to?

Also, why this number is greater than existing cpu sometimes,

$ cat /proc/1800/stat | awk '{print $39}'
17
$ cat /sys/devices/system/cpu/online
0-15
$ ps -eLo pid,psr | grep 1800
 1800  14

What exactly (39) processor represents in /proc/[pid[/stat file ?

Seems, like lack of documentation.

0

This is my silly mistake

I am adding here instead of deleting , in case someone also does this mistake

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

If comm has space/s, No of fields differ and 39th field doesn't remain 39th being split by space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.