🔍 See Original Question on Stack Overflow 🔗
Purpose of /proc/thread-self?
August 23, 2018
November 24, 2022
Copy to clipboard: false
I’m fairly new to Linux OS programming world. I’m working on a project to control Intel CPU (turbo boost, hyper threading, min & max scaling frequencies to solve problems for other users). Whilst investigating
/proc/stat for CPU utilization I stumbled across this:
$ ll /proc/thread-self lrwxrwxrwx 1 root root 0 Aug 22 04:26 /proc/thread-self -> 9389/task/9389/ $ ll /proc/self lrwxrwxrwx 1 root root 0 Aug 22 04:26 /proc/self -> 29420/ $ ll /proc/self lrwxrwxrwx 1 root root 0 Aug 22 04:26 /proc/self -> 29636/ $ ll /proc/thread-self lrwxrwxrwx 1 root root 0 Aug 22 04:26 /proc/thread-self -> 30021/task/30021/
self are constantly changing every time you list the symbolic links with
ll. The date and time remain at the last boot time though.
I did a little digging and found this email chain in 2014:
This patchset implements
/proc/thread-selfa magic symlink that solves
a couple of problems.
…. further down the email says:
proc: Have net show up under /proc/<tgid>/task/<tid> proc: Implement /proc/thread-self to point at the directory of the current thread proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net proc: Point /proc/mounts at /proc/thread-self/mounts instead of /proc/self/mounts
How dp the symbolic link(s) work? Or how do we use them for meaningful analysis/display of what Linux is doing? Or are they simply meaningless and to be ignored as “fluff”?