Traditional Culture Encyclopedia - Traditional stories - Difference between process and thread
Difference between process and thread
Process
An application program that runs in memory. Each process has its own separate piece of memory space, and a process can have multiple threads, for example, in Windows, a running xx.exe is a process.
Thread
An execution task (control unit) in a process that is responsible for the execution of the program in the current process. A process has at least one thread, a process can run multiple threads, and multiple threads can **** enjoy data.
With the process is different from the same kind of multiple threads *** enjoy the process of the heap and method area resources, but each thread has its own program counter, virtual machine stack and local method stack, so the system in the spawning of a thread, or switching between the various threads to do the work, the burden to be much smaller than the process, and because of this, the thread is also known as a lightweight process.
Threads have many of the characteristics of traditional processes, so they are also called light processes (Light-Weight Process) or process elements; and the traditional process is called a heavy process (Heavy-Weight Process), which is equivalent to a task with only one thread. . In operating systems that have introduced threads, it is common for a process to have several threads and to contain at least one thread.
Fundamental difference: process is the basic unit of operating system resource allocation, while thread is the basic unit of processor task scheduling and execution
Resource overhead: each process has its own independent code and data space (program context), and there is a large overhead for switching between programs; thread can be regarded as a lightweight process, and the same type of thread *** enjoys code and data space. Each thread has its own independent run stack and program counter (PC), the overhead of switching between threads is small.
Containment relationship: if there are multiple threads within a process, the execution process is not a single line, but multiple lines (threads) *** with the completion of the process; threads are part of the process, so the threads are also known as lightweight process or lightweight process.
Memory allocation: threads of the same process *** enjoy the address space and resources of the process, while the address space and resources between the processes are independent of each other
Impact relationship: after a process crashes, it will not have an impact on the other processes in protected mode, but a thread crashes the whole process is dead. So multiple processes are more robust than multiple threads.
Execution process: each independent process has a program to run the entrance, sequential execution sequence and program exit. But threads can not be executed independently, must be dependent on the application program, by the application program to provide multiple thread execution control, both can be concurrently executed
- Related articles
- What are the working environment and pay conditions for sewing workers?
- The Differences of Red in Chinese and Western Cultures
- The basic form of common toddler craft activities have toys?
- How to make handmade lanterns for Mid-Autumn Festival and Chinese New Year? In fact, it is very simple, video tutorials worth collecting!
- Are there any special snacks near the school?
- Changes of Yiwu Market
- Ten ways to eat green peppers, I don't just like you.
- 2022 Mid-Autumn Festival holiday notice template is simple (selected 14)
- Handwritten newspaper with the theme of inheriting civilization and love
- Simple content of red scarf handwritten newspaper