Skip to main content
deleted 7 characters in body
Source Link
user147505
user147505

Internally, there is no such thing as processes or threads in the linux kernel. Processes and threads are a mostly userland concept, the kernel itself only sees "tasks", which are a schedulable object that may share none, some, or all of its resources with other tasks. Threads are tasks that have been configured to share most of its resources (address space, mmaps, pipes, open file handlers, sockets, etc) with the parent task, and processes are tasks that have been configured to share minimal resources with the parent task.

When you use the Linux API directly (clone(), instead of fork() and pthread_create()), then you have much more flexibility in defining how much resources to share or not share, and you can create create tasks that are neither fully a process nor fully a thread. If you use these low-level calls directly, it's also possible to create a task with a new TGID (thus treated as a process by most userland tools) that actually share all of its resources with the parent task, or vice versa, to create a task with shared TGID (thus treated as a thread by most userland tools) that share no resource with its parent task.

While Linux 2.4 implements TGID, this is mostly just for the benefit of resource accounting. Many users and userspace tool find it useful to be able to group related tasks together and report their resource usage together.

The implementation of tasks in Linux is much more fluid than the processes and threads worldview presented by userspace tools.

Internally, there is no such thing as processes or threads in the linux kernel. Processes and threads are a mostly userland concept, the kernel itself only sees "tasks", which are a schedulable object that may share none, some, or all of its resources with other tasks. Threads are tasks that have been configured to share most of its resources (address space, mmaps, pipes, open file handlers, sockets, etc) with the parent task, and processes are tasks that have been configured to share minimal resources with the parent task.

When you use the Linux API directly (clone(), instead of fork() and pthread_create()), then you have much more flexibility in defining how much resources to share or not share, and you can create create tasks that are neither fully a process nor fully a thread. If you use these low-level calls directly, it's also possible to create a task with a new TGID (thus treated as a process by most userland tools) that actually share all of its resources with the parent task, or vice versa, to create a task with shared TGID (thus treated as a thread by most userland tools) that share no resource with its parent task.

While Linux 2.4 implements TGID, this is mostly just for the benefit of resource accounting. Many users and userspace tool find it useful to be able to group related tasks together and report their resource usage together.

The implementation of tasks in Linux is much more fluid than the processes and threads worldview presented by userspace tools.

Internally, there is no such thing as processes or threads in the linux kernel. Processes and threads are a mostly userland concept, the kernel itself only sees "tasks", which are a schedulable object that may share none, some, or all of its resources with other tasks. Threads are tasks that have been configured to share most of its resources (address space, mmaps, pipes, open file handlers, sockets, etc) with the parent task, and processes are tasks that have been configured to share minimal resources with the parent task.

When you use the Linux API directly (clone(), instead of fork() and pthread_create()), then you have much more flexibility in defining how much resources to share or not share, and you can create tasks that are neither fully a process nor fully a thread. If you use these low-level calls directly, it's also possible to create a task with a new TGID (thus treated as a process by most userland tools) that actually share all of its resources with the parent task, or vice versa, to create a task with shared TGID (thus treated as a thread by most userland tools) that share no resource with its parent task.

While Linux 2.4 implements TGID, this is mostly just for the benefit of resource accounting. Many users and userspace tool find it useful to be able to group related tasks together and report their resource usage together.

The implementation of tasks in Linux is much more fluid than the processes and threads worldview presented by userspace tools.

Source Link
Lie Ryan
  • 1.3k
  • 7
  • 13

Internally, there is no such thing as processes or threads in the linux kernel. Processes and threads are a mostly userland concept, the kernel itself only sees "tasks", which are a schedulable object that may share none, some, or all of its resources with other tasks. Threads are tasks that have been configured to share most of its resources (address space, mmaps, pipes, open file handlers, sockets, etc) with the parent task, and processes are tasks that have been configured to share minimal resources with the parent task.

When you use the Linux API directly (clone(), instead of fork() and pthread_create()), then you have much more flexibility in defining how much resources to share or not share, and you can create create tasks that are neither fully a process nor fully a thread. If you use these low-level calls directly, it's also possible to create a task with a new TGID (thus treated as a process by most userland tools) that actually share all of its resources with the parent task, or vice versa, to create a task with shared TGID (thus treated as a thread by most userland tools) that share no resource with its parent task.

While Linux 2.4 implements TGID, this is mostly just for the benefit of resource accounting. Many users and userspace tool find it useful to be able to group related tasks together and report their resource usage together.

The implementation of tasks in Linux is much more fluid than the processes and threads worldview presented by userspace tools.