当前位置:网站首页>Difference between process and thread

Difference between process and thread

2022-07-07 09:27:00 wrdoct

Difference between process and thread

 process :
 An application that runs in memory .
 Each process has its own independent memory space , A process can have multiple threads .

 Threads :
 An execution task in the process ( control unit ), Responsible for the execution of programs in the current process .
 A process has at least one thread , A process can run multiple threads , Multiple threads can share data .

Fundamental difference : Processes are performed by the operating system Resource allocation The basic unit of , Thread is Independent scheduling The basic unit of .

address space : Process includes Independent address space , Threads do not have their own independent address space , it Share the space of the owning process .

resources : When the system is running Allocate resources for each process , Instead of allocating resources to threads , The resource used by a thread comes from the resource of the process it belongs to .

expenses : Between processes Switching costs a lot , Switching between threads The cost is relatively small ; Creating a thread costs less than a process .

signal communication Interthread communication Communication between processes More convenient .

Inclusion relation Thread is A lightweight process , It's part of the process .

Influence relationships : One After the process crashes , In protected mode No impact on other processes , however One thread crashes and the whole process dies . So multiprocessing is more robust than multithreading .

原网站

版权声明
本文为[wrdoct]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070648212369.html