当前位置:网站首页>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
边栏推荐
- What are the common problems of DTU connection
- Using an example to understand the underlying processing mechanism of JS function
- 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
- Diamond standard
- window系统 本机查找端口号占用方法
- How to play sortable JS vuedraggable to realize nested drag function of forms
- Vue communication and cross component listening state Vue communication
- Try to build my mall from scratch (2): use JWT to protect our information security and perfect swagger configuration
- ES6 learning notes (3): teach you to use js object-oriented thinking to realize the function of adding, deleting, modifying and checking tab column
- 【学习】接口测试用例编写和测试关注点
猜你喜欢
Live broadcast preview | micro service architecture Learning Series live broadcast phase 3
The importance of big data application is reflected in all aspects
Zero basis to build a web search engine of its own
Small program introduction to proficient (2): understand the four important files of small program development
An article taught you to use HTML5 SVG tags
JVM内存分配 -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m
image operating system windows cannot be used on this platform
jenkins安装部署过程简记
2020年第四届中国 BIM (数字建造)经理高峰论坛即将在杭举办
Bitcoin once exceeded 14000 US dollars and is about to face the test of the US election
随机推荐
Outsourcing is really difficult. As an outsourcer, I can't help sighing.
大数据处理黑科技:揭秘PB级数仓GaussDB(DWS) 并行计算技术
window系统 本机查找端口号占用方法
How to understand Python iterators and generators?
小游戏云开发入门
Introduction to Google software testing
StickEngine-架构12-通信协议
华为Mate 40 系列搭载HMS有什么亮点?
C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
Introduction to the structure of PDF417 bar code system
PHP application docking justswap special development kit【 JustSwap.PHP ]
统计项目代码行数
What are PLC Analog input and digital input
Application of restful API based on MVC
StickEngine-架构11-消息队列(MessageQueue)
【转发】查看lua中userdata的方法
nacos、ribbon和feign的簡明教程
ES6 learning notes (3): teach you to use js object-oriented thinking to realize the function of adding, deleting, modifying and checking tab column
Read the advantages of Wi Fi 6 over Wi Fi 5 in 3 minutes
Behind the record breaking Q2 revenue of Alibaba cloud, the cloud opening mode is reshaping