当前位置:网站首页>用户级线程和内核级线程
用户级线程和内核级线程
2022-06-29 08:41:00 【KingOfMyHeart】
线程模型
一对一线程模型

多对一的线程模型

N对M的线程模型

线程的两种实现方式
用户级线程
实现在用户态的线程实例,用一个TCB(Thread Control Block)来描述一个用户线程,该TCB存放在用户态。
- 内核看不到用户级线程,对于内核来讲,只能看到当前的进程,在当前进程中创建的线程无法被操作系统调度;
- 用户级线程的创建,销毁,以及切换都是特别快的,不需要用户态和内核态来回切换;
- 当一个用户线程阻塞或者陷入内核,那么当前整个进程都会阻塞,其他的用户线程也将不能使用(可以考虑使用异步调用缓解);
- 进程中的所有用户线程需要主动让出CPU,否则一次性将CPU时间片耗完,因为对于内核来讲,只能看到进程,只能将时间片分配给当前进程;
- 每个进程可以自定义线程调度算法。
用户级线程是由一些应用程序中的线程库实现。
内核级线程
实现在内核态的线程实例,用一个TCB(Thread Control Block)来描述一个用户线程,该TCB存放在内核态,内核可以直接进行调度管理。
- 线程的创建,终止以及切换开销较大,都是由内核完成;
- 内核能感知到线程的存在,被操作系统管理,受操作系统调度;
- 内核时间片的分配是以线程为单位的,内核是将一整个时间片分配给线程的。
协程
协程 = 用户级线程 + 调度器
边栏推荐
- 记微信小程序setData动态修改字段名
- Mongodb persistence
- Detecting and counting tiny faces
- 微信小程序底部导航栏中间突出
- How to implement observer mode
- Pytorch summary learning series - broadcast mechanism
- Wechat applet sharing page, sharing to the circle of friends
- Macros, functions, and inline functions
- 深入RC、RS、DaemonSet、StatefulSet(七)
- 微信小程序项目:tab导航栏
猜你喜欢

Handwriting Redux thunk

五心公益红红娘团队

The former security director of Uber faced fraud allegations and concealed the data leakage event

笔试题“将版本号从大到小排列”

Laravel 8 enables the order table to be divided by month level

记自定义微信小程序顶部导航栏
![[target detection] | indicator a probabilistic challenge for object detection](/img/82/7b830d44bed7b1509cb0cdfed88e3e.png)
[target detection] | indicator a probabilistic challenge for object detection

记一些笔试题

pytorch总结学习系列-操作

SSD改进CFENet
随机推荐
Difference between factory mode and strategy mode
Pytorch summary learning series - data manipulation
Training view (issue temporary storage)
js轮播图观后重做(较长的完整版,可运行)
pytorch总结学习系列-数据操作
Jar package and war package
Uni app gets the route URL of the current page
实例报错IOPub data rate exceeded
Understanding of singleton mode
easyexecl导出100万行execl报字体错误的解决办法
微信小程序项目:微信小程序页面布局
Wechat applet wx Navigateback returns the parameters carried on the previous page
SSD improvements cfenet
Iso16000-9 testing of volatile organic compounds in building products and furniture
Western Polytechnic University, one of the "seven national defense schools", was attacked by overseas networks
什么是超融合?与传统架构有什么区别?.
网络安全问题
微信小程序子组件向页面传值(父子组件间的通信)带源码
Twinmotion 初学者教程
记微信小程序分享代码片段