4

I have read that a process and a thread are the same thing in Linux, for example in this question it says:

There is absolutely no difference between a thread and a process on Linux.

But I don't understand how can a process and a thread means the same thing. I mean a thread is what gets executed by the CPU, and a process is simply an "enclosure" for the threads which allows the threads to have shared memory. This image shows the relationship between a process and its threads:

enter image description here

So clearly a process and a thread does not mean the same thing!

rony_t
  • 413
  • 4
  • 9
  • 1
    `There is absolutely no difference between a thread and a process on Linux.` - from the [scheduler](https://en.wikipedia.org/wiki/Scheduling_(computing)#Process_scheduler) point of view, it may be true – Arkadiusz Drabczyk Jun 14 '17 at 12:24
  • Possible duplicate of [Threads vs Processes in Linux](https://stackoverflow.com/questions/807506/threads-vs-processes-in-linux) – Cody Gray - on strike Jun 14 '17 at 12:33
  • 1
    Different points of view: You are thinking about processes and threads in terms of what they mean to a developer. The question that you cited talks about implementation details. But, as PSkocik said in his answer below, that question now is out-of-date: The Linux implementation has changed. – Solomon Slow Jun 14 '17 at 13:33
  • This is a classic case of getting bogged down by terminology. People are using different definitions of what constitutes a "thread" and "process." – user3344003 Jun 15 '17 at 19:50

1 Answers1

5

Linux didn't use to have special support for (POSIX) threads, and it simply treated them as processes that shared their address space as well as a few other resources (filedescriptors, signal actions, ...) with other "processes".

That implementation, while elegant, made certain things required for threads by POSIX difficult, so Linux did end up gaining that special support for threads and your premise is now no longer true.

Nevertheless, processes and threads still both remain represented as tasks within the kernel (but now the kernel has support for grouping those tasks into thread groups as well and APIs for working with those ((tgkill, tkill, exit_group, ...)).

You can google LinuxThreads and NPTL threads to learn more about the topic.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142