当前位置:网站首页>2020-11-06:go中,谈一下调度器。
2020-11-06:go中,谈一下调度器。
2020-11-06 22:43:00 【福大大架构师每日一题】
福哥答案2020-11-06:
·MPG模型:goroutine的并发模型可以归纳为MPG模型;
·MPG概念:线程(machine,系统线程,物理线程)-内核(processor)-协程(goroutine,用户线程,逻辑线程);
·多对多调度模型:整体调度遵循多对多模型,多个协程(约百万级)同时调度在多个线程(约千级)下;
·LRQ(LocalRunningQueue):本地运行队列,一个M执行在一个P的上下文中,P中挂载着一个G队列;
·GRQ(GlobalRunningQueue):全局运行队列,G没有初始化时或者没有LRQ可供挂载时就被丢入GRQ;
·GRQ=>LRQ:MP会在LRQ执行完毕检查GRQ,并从中窃取任务挂载到当前LRQ中执行,平时也会定期检查;
·调度的目的:调度的目的是防止线程堵塞、闲置、被OS挂起(syscall);
·防止线程M堵塞:G1协程IO时脱离MP,G2从当前MP的LRQ中弹出并执行;
·防止线程M闲置:M1闲置时,会从M2的LRQ中窃取一半任务,挂载到自己的LRQ中执行;
·防止线程M被OS挂起(syscall):P带着LRQ挂到其它线程的下面执行,当syscall结束时,M会尝试将G0挂载到其它LRQ中或GRQ中;
详细go调度器模型参考:
Go语言中文网:https://studygolang.com/articles/9610
简书:https://www.jianshu.com/p/f9024e250ac6
版权声明
本文为[福大大架构师每日一题]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4553401/blog/4706933
边栏推荐
- STM32F030K6T6兼容替换灵动MM32F031K6T6
- Common mathematical basic formulas of recursive and backtracking algorithms
- A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
- Unexpected element.. required element
- Mobile pixel adaptation scheme
- 打工人好物——磨炼钢铁意志就要这样高效的电脑
- 8.Swarm创建维护和水平扩展Service
- How to add modules to nginx image?
- Win7 AppCrash (solution)
- 小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
猜你喜欢
How does LeadTools detect, read and write barcodes
How to use Gantt chart layers and filters
August 18, 2020: introduce Mr process?
ado.net and asp.net The relationship between
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
What grammar is it? ]
非易失性MRAM存储器应用于各级高速缓存
JVM class loading mechanism
2020 database technology conference helps technology upgrade
[learning] interface test case writing and testing concerns
随机推荐
Points to be considered when deleting mapping field of index in ES
Detailed software engineering -- the necessary graphs in each stage
实验一
PHP后门隐藏技巧
Getting started with varhart xgantt
2020-08-15: under what circumstances should data tasks be optimized?
Count the number of project code lines
南京标志设计,logo设计公司
What are the highlights of Huawei mate 40 series with HMS?
Google browser realizes video playback acceleration function
August 18, 2020: introduce Mr process?
Nanjing logo design and production, guide VI system design
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
In 2020, how can wechat seal numbers be quickly lifted?
STM32F030F4P6兼容灵动微MM32F031F4P6
Qt音视频开发46-视频传输UDP版
The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
2020 database technology conference helps technology upgrade
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification