Timeline for The program pstree and htop showing threads with unique PIDS. How is this possible?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 6, 2014 at 20:25 | comment | added | Hack Saw | More succinctly, the only difference between real threads and processes, in linux, is that a threads shares memory with another process, and a process doesn't. As far as the proc directory goes, and the machinery behind it, and more importantly the scheduler, it's just another process. | |
| Nov 6, 2014 at 14:40 | comment | added | stantona | I think you kind of elaborated on what I said, no?? | |
| Nov 6, 2014 at 5:57 | comment | added | Hack Saw | No. In Linux, if you want to make something which can be scheduled separately from the main thread, you can either declare a new thread, or fork. In either case, the first thing which happens is a clone, which duplicates the process without making a new memory area for it. If it's forking, the next thing which happens is an allocation of a separated process memory space. See the linux function clone(2) | |
| Nov 6, 2014 at 1:08 | comment | added | stantona | Threads belong to processes and share the process's memory space. They are definitely not a separate process from the process that created them. When you say "a thread is often a clone of a process", you might be thinking of the fork system call, which creates a child process, not a thread. | |
| Nov 6, 2014 at 0:40 | history | answered | Hack Saw | CC BY-SA 3.0 |