Demo: Threads Share the Address Space¶
Run¶
ps -e -o pid,comm,nlwp --sort -nlwp | head
ls /proc/<pid>/task
diff <(cat /proc/<pid>/maps) <(cat /proc/<pid>/task/<tid>/maps)
Ask¶
- The
diffis empty: every thread sees the samemaps. What, then, does each thread have of its own? - The first task has the same id as the process. Which thread is that?