当前位置:网站首页>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
边栏推荐
- Building a new generation cloud native data lake with iceberg on kubernetes
- 实用工具类函数(持续更新)
- IPFs rudder filecoin landing at the same time, fil currency price broke a thousand
- Introduction to the structure of PDF417 bar code system
- An article will take you to understand SVG gradient knowledge
- To Lianyun analysis: why is IPFs / filecoin mining so difficult?
- 常用SQL语句总结
- image operating system windows cannot be used on this platform
- Metersphere developer's Manual
- ERD-ONLINE 免费在线数据库建模工具
猜你喜欢
What are manufacturing and new automation technologies?
With this artifact, quickly say goodbye to spam messages
It's time for your financial report to change to a more advanced style -- financial analysis cockpit
意外的元素..所需元素..
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
事务的隔离级别与所带来的问题
What is the tensor in tensorflow?
An article will introduce you to HTML tables and their main attributes
解决 WPF 绑定集合后数据变动界面却不更新的问题
The method of realizing high SLO on large scale kubernetes cluster
随机推荐
Summary of front-end performance optimization that every front-end engineer should understand:
How to hide part of barcode text in barcode generation software
Metersphere developer's Manual
Flink's datasource Trilogy 2: built in connector
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
Even liver three all night, jvm77 high frequency interview questions detailed analysis, this?
jenkins安装部署过程简记
Multi robot market share solution
代码生成器插件与Creator预制体文件解析
How to understand Python iterators and generators?
Those who have worked in China for six years and a million annual salary want to share these four points with you
How to turn data into assets? Attracting data scientists
An article taught you to download cool dog music using Python web crawler
[efficiency optimization] Nani? Memory overflow again?! It's time to sum up the wave!!
Using an example to understand the underlying processing mechanism of JS function
CloudQuery V1.2.0 版本发布
ES6 learning notes (4): easy to understand the new grammar of ES6
es创建新的索引库并拷贝旧的索引库 实践亲测有效!
ES6 learning notes (5): easy to understand ES6's built-in extension objects
The legality of IPFs / filecoin: protecting personal privacy from disclosure