当前位置:网站首页>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
边栏推荐
- Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
- What knowledge do Python automated testing learn?
- Isn't data product just a report? absolutely wrong! There are university questions in this category
- hdu3974 Assign the task線段樹 dfs序
- 使用 Iceberg on Kubernetes 打造新一代雲原生資料湖
- Zero basis to build a web search engine of its own
- PHP application docking justswap special development kit【 JustSwap.PHP ]
- FastThreadLocal 是什么鬼?吊打 ThreadLocal 的存在!!
- es创建新的索引库并拷贝旧的索引库 实践亲测有效!
- Live broadcast preview | micro service architecture Learning Series live broadcast phase 3
猜你喜欢
This project allows you to quickly learn about a programming language in a few minutes
Behind the record breaking Q2 revenue of Alibaba cloud, the cloud opening mode is reshaping
How about small and medium-sized enterprises choose shared office?
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
Get twice the result with half the effort: automation without cabinet
如何对数据库账号权限进行精细化管理?
Zero basis to build a web search engine of its own
Flink's datasource Trilogy 2: built in connector
A small goal in 2019 to become a blog expert of CSDN
Zero basis to build a web search engine of its own
随机推荐
Staying up late summarizes the key points of report automation, data visualization and mining, which is different from what you think
Behind the record breaking Q2 revenue of Alibaba cloud, the cloud opening mode is reshaping
This project allows you to quickly learn about a programming language in a few minutes
统计项目代码行数
ado.net和asp.net的关系
JVM内存分配 -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m
JNI-Thread中start方法的呼叫與run方法的回撥分析
開源一套極簡的前後端分離專案腳手架
意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
ORA-02292: 违反完整约束条件 (MIDBJDEV2.SYS_C0020757) - 已找到子记录
GitHub: the foundation of the front end
es创建新的索引库并拷贝旧的索引库 实践亲测有效!
行为型模式之解释器模式
What is alicloud's experience of sweeping goods for 100 yuan?
(2) ASP.NET Core3.1 Ocelot routing
一路踩坑,被迫聊聊 C# 代码调试技巧和远程调试
A small goal in 2019 to become a blog expert of CSDN
Application of restful API based on MVC
Will blockchain be the antidote to the global epidemic accelerating the transformation of Internet enterprises?
An article will take you to understand CSS3 fillet knowledge