当前位置:网站首页>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
边栏推荐
- The isolation level of transaction and its problems
- 如何创建交互式内核密度图表
- PHP后门隐藏技巧
- Detailed software engineering -- the necessary graphs in each stage
- image operating system windows cannot be used on this platform
- Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
- .NETCore3.1+Vue.js打造的低代码工作流引擎
- Jenkins入门(二)声明式流水线Jenkins Pipeline
- How to create an interactive kernel density chart
- 磁存储芯片STT-MRAM的特点
猜你喜欢
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
如何才能快速正确的部署甘特图
甘特图对活动进行分组教程
Mobile pixel adaptation scheme
2020-08-20: the difference between go and python?
About Devops seven misunderstandings, 99% of people have been hit!
2020 database technology conference helps technology upgrade
实验一
Jenkins installation and deployment process
超高频RFID医疗血液管理系统应用
随机推荐
Application of UHF RFID medical blood management system
Code generator plug-in and creator preform file analysis
The Interpreter pattern of behavior pattern
Detailed software engineering -- the necessary graphs in each stage
Google browser realizes video playback acceleration function
jenkins pipline stage 设置超时
September 3, 2020: naked writing algorithm: loop matrix traversal.
RFID fixed assets management system for fire equipment
Configuration of AP hotspot on xunwei-imx6ull development board
8. Swarm creates maintenance and horizontal extension service
Git SSH bad permissions
7.Swarm搭建集群
The memorandum model of behavior model
Common mathematical basic formulas of recursive and backtracking algorithms
高速公路二维码定位报警系统
In 2020, how can wechat seal numbers be quickly lifted?
甘特图对活动进行分组教程
New features of vue3
How does LeadTools detect, read and write barcodes
python3操作gitlab