2

Process Control Blocks expose the /proc file system which allows PCBs to be read by users. Is there a similar file system for Thread Control Blocks? If not, is there a tool to read their contents (bonus points if it supports high-frequency sampling)?

2
  • 1
    Does /proc/.../task give the info you’re after? Commented Apr 23, 2020 at 21:29
  • I'm interested in the program counter, register contents, and thread state. Where would I find that in the proc/{pid}/task/{tid} directory? Commented Apr 23, 2020 at 21:38

1 Answer 1

4

The Kernel has a Thread Control Block (TCB). To view the information you're after, I would use -

# cat /proc/PID/task/PID/status

So, to view thread information for a process that has the PID 12345 -

# cat /proc/12345/task/12345/status

There's also libproc, available in procps. Sorry, I couldn't provide good documentation on that.

3
  • Which entries in the cat .../status output correspond to program counter, register contents, and thread state? Commented Apr 23, 2020 at 22:22
  • Please consult the docs at man7.org/linux/man-pages/man5/proc.5.html Commented Apr 23, 2020 at 23:16
  • Another excellent piece of insights at this blog Commented Apr 23, 2020 at 23:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.