当前位置:网站首页>2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
2020-11-06 21:50:00 【福大大架构师每日一题】
福哥答案2020-08-29:
1.根本区别
进程:资源调度最小单位。
线程:CPU调度最小单位。
2.地址空间
进程:进程有自己独立的地址空间,每启动一个进程,系统都会为其分配地址空间,建立数据表来维护代码段、堆栈段和数据段。
线程:线程没有独立的地址空间,同一进程的线程共享本进程的地址空间。
3.内存和files共享
进程:当创建一个进程的时候,mm_struct会指向另外一块地址,使用copy-on-write进行复制。
线程:而创建一个线程的时候,mm_struct会指向父进程的同一块虚拟内存区域,所以会有资源冲突问题。
不论线程和进程,在linux中的创建都是很快速的。
4.块
进程:进程控制块PCB。一个进程用ProcessControlBlock上的一个entry记录其基本信息(pid,state,priority等),进程会被操作系统分配一个内存逻辑地址空间,即其拥有一段内存空间供使用。
线程:线程控制块TCB。线程是进程内负责执行一项任务的单元,这个单元用ThreadControlBlock上的一个entry记录其基本信息(tid,state,priority,counter,register info等),这个单元有着自己的stack来用于任务执行。
5.系统开销
进程:进程执行开销大。
线程:线程执行开销小。
6.切换速度
进程:切换相对慢。
线程:切换相对快。
版权声明
本文为[福大大架构师每日一题]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4553401/blog/4536632
边栏推荐
- Contract trading system development | construction of smart contract trading platform
- The legality of IPFs / filecoin: protecting personal privacy from disclosure
- Filecoin has completed a major upgrade and achieved four major project progress!
- C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
- Small program introduction to proficient (2): understand the four important files of small program development
- C語言I部落格作業03
- Network programming NiO: Bio and NiO
- Summary of front-end interview questions (C, s, s) that front-end engineers need to understand (2)
- An article will take you to understand CSS alignment
- 2020年第四届中国 BIM (数字建造)经理高峰论坛即将在杭举办
猜你喜欢

常用SQL语句总结

Some operations kept in mind by the front end foundation GitHub warehouse management

Swagger 3.0 brushes the screen every day. Does it really smell good?

Metersphere developer's Manual

What are the common problems of DTU connection

CloudQuery V1.2.0 版本发布

A small goal in 2019 to become a blog expert of CSDN

【:: 是什么语法?】

What are the criteria for selecting a cluster server?

git远程库回退指定版本
随机推荐
实用工具类函数(持续更新)
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
Building a new generation cloud native data lake with iceberg on kubernetes
Ronglian completed US $125 million f round financing
The AI method put forward by China has more and more influence. Tianda et al. Mined the development law of AI from a large number of literatures
An article will introduce you to HTML tables and their main attributes
EOS founder BM: what's the difference between UE, UBI and URI?
(2) ASP.NET Core3.1 Ocelot routing
谷歌浏览器实现视频播放加速功能
What is alicloud's experience of sweeping goods for 100 yuan?
PHP application docking justswap special development kit【 JustSwap.PHP ]
How to turn data into assets? Attracting data scientists
Contract trading system development | construction of smart contract trading platform
Small program introduction to proficient (2): understand the four important files of small program development
開源一套極簡的前後端分離專案腳手架
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
Swagger 3.0 brushes the screen every day. Does it really smell good?
Take you to learn the new methods in Es5
Git rebase is in trouble. What to do? Waiting line
Network programming NiO: Bio and NiO