Linux — /proc/pid Directory, Part Five

Deep dive into Linux /proc directory

Tony
Geek Culture

--

/proc/pid/schedstat

This file contains process level scheduling information. There are three fields in this file correlating for that process to:

  • Time spent on the cpu (in nanoseconds), this value is the same as the se.sum_exec_runtime
  • Time spent waiting on a runqueue (in nanoseconds), this value is the same as se.wait_sum
  • Number of timeslices run on this cpu

Form example:


$ cat /proc/8733/schedstat
5726055470233 30451531 6336

/proc/pid/sessionid

The session id is the identifier of a process’ session. Sessions are a concept tied to shell job control, at a level above process groups; all processes in a given session share the same controlling terminal. In non-graphical environments, sessions can be thought of as login sessions (at least, that’s part of the original idea; they mustn’t be confused with systemd sessions which track login sessions in systemd-based environments).

For example:

$ cat /proc/29218/sessionid
15

$ loginctl show-session 15
Id=15
User=1001
Name=txu
Timestamp=Thu 2023-01-05 07:40:16 EST
TimestampMonotonic=5979415652…

--

--