当前位置:网站首页>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
边栏推荐
- Network programming NiO: Bio and NiO
- DC-1靶機
- C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
- Elasticsearch Part 6: aggregate statistical query
- Take you to learn the new methods in Es5
- 消息队列(MessageQueue)-分析
- Use modelarts quickly, zero base white can also play AI!
- 代码重构之法——方法重构分析
- 游戏开发中的新手引导与事件管理系统
- The legality of IPFs / filecoin: protecting personal privacy from disclosure
猜你喜欢

Staying up late summarizes the key points of report automation, data visualization and mining, which is different from what you think

ES6 learning notes (4): easy to understand the new grammar of ES6

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

行为型模式之备忘录模式

Get twice the result with half the effort: automation without cabinet

大数据处理黑科技:揭秘PB级数仓GaussDB(DWS) 并行计算技术

Basic usage of Vue codemirror: search function, code folding function, get editor value and verify in time

小游戏云开发入门

How to turn data into assets? Attracting data scientists

Python basic variable type -- list analysis
随机推荐
The importance of big data application is reflected in all aspects
DC-1靶機
Axios learning notes (2): easy to understand the use of XHR and how to package simple Axios
行为型模式之解释器模式
代码生成器插件与Creator预制体文件解析
Contract trading system development | construction of smart contract trading platform
Description of phpshe SMS plug-in
StickEngine-架构11-消息队列(MessageQueue)
代码重构之法——方法重构分析
游戏主题音乐对游戏的作用
Zero basis to build a web search engine of its own
Multi robot market share solution
游戏开发中的新手引导与事件管理系统
C#和C/C++混合编程系列5-内存管理之GC协同
ERD-ONLINE 免费在线数据库建模工具
The method of realizing high SLO on large scale kubernetes cluster
A small goal in 2019 to become a blog expert of CSDN
使用 Iceberg on Kubernetes 打造新一代雲原生資料湖
What course of artificial intelligence? Will it replace human work?
Bitcoin once exceeded 14000 US dollars and is about to face the test of the US election