Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the difference between threads and processes in linux systems

Shulou Source: shulou.com Published: 2022-06-02 21:27:30 09月22日 Update

What is the difference between threads and processes in linux systems? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

I. the concept of thread and process

Process: a running program that is the smallest unit of resources allocated by the system.

Thread: is a path executed in a process and is the smallest unit of system scheduling.

Second, the relationship between thread and process

1. A process can have multiple threads, and a thread can only belong to one process (subordinate).

2. All threads under the same process share all resources (resources) under the process.

3. What is really running on the processor is a thread rather than a process. A thread is an execution unit within a process and a schedulable entity (running entity) within a process.

III. The difference between threads and processes

Scheduling: the thread is the basic unit of scheduling and the process is the basic unit of owning resources.

Concurrency: can be executed concurrently between processes and threads.

Resources: a process is an independent unit that owns resources. Threads do not own system resources, but can access resources belonging to the process. Threads have their own stack space and program counters.

System overhead: the process overhead is greater than the thread overhead, and the context switching speed of the thread is much faster than that between processes.

For multiple threads within each process, static data segment (including global variables, static objects), Heap (space allocated by heap, malloc, and new) is shared. Each thread has its own independent Stack (stack) that stores local variables.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Processes threads resources systems units scheduling running minimum up and down context between variables multiple entities overhead programs space allocation switching help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft vpn Shulou Technology Huawei