当前位置:网站首页>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
边栏推荐
- Summary of common SQL statements
- Introduction to Jenkins (2) declarative pipeline
- The isolation level of transaction and its problems
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
- Bluetooth broadcast chip for Shanghai giant micro
- Markdown tricks
- Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
- How to use Gantt chart layers and filters
- August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
- 2020-08-20: the difference between go and python?
猜你喜欢
RFID fixed assets management system for fire equipment
Cloudquery v1.2.0 release
Message queue - Analysis
Application of UHF RFID medical blood management system
Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)
[elastic search engine]
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
实验一
Countdown | 2020 PostgreSQL Asia Conference - agenda arrangement of Chinese sub Forum
ImageMagick - 添加水印
随机推荐
【涂鸦物联网足迹】物联网基础介绍篇
VARCHART XGantt如何在日历上表示工作日
LEADTOOLS如何检测,读取和写入条形码
Common syntax corresponding table of mongodb and SQL
插件Bilibili新版0.5.5
QT audio and video development 46 video transmission UDP version
移动端像素适配方案
南京标志设计,logo设计公司
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
Common mathematical basic formulas of recursive and backtracking algorithms
2020-08-20: the difference between go and python?
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
Experiment one
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
2020-08-15: under what circumstances should data tasks be optimized?
How to create an interactive kernel density chart
消防器材RFID固定资产管理系统
Utility class functions (continuous update)
Application of UHF RFID medical blood management system
python3操作Jenkins模块api