当前位置:网站首页>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
边栏推荐
- 预留电池接口,内置充放电电路及电量计,迅为助力轻松搞定手持应用
- 应用层软件开发教父教你如何重构,资深程序员必备专业技能
- Points to be considered when deleting mapping field of index in ES
- 20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
- How to create an interactive kernel density chart
- vue3 新特性
- 8. Swarm creates maintenance and horizontal extension service
- Epu360: all the H5 templates you want are here, e-book, big turntable, red envelope rain, questionnaire survey
- QT audio and video development 46 video transmission UDP version
- Common syntax corresponding table of mongodb and SQL
猜你喜欢
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
How to use Gantt chart layers and filters
应用层软件开发教父教你如何重构,资深程序员必备专业技能
心理咨询app开发所具备的优点与功能
2020-09-04: do you understand the function call convention?
JVM class loading mechanism
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
Benefits and functions of auto maintenance app development
随机推荐
PHP backdoor hiding skills
超高频RFID医疗血液管理系统应用
Method of code refactoring -- Analysis of method refactoring
Erd-online free online database modeling tool
ado.net and asp.net The relationship between
To solve the problem that the data interface is not updated after WPF binding set
Design of NAND flash interface control
Dynamsoft barcode reader v7.5!
如何创建交互式内核密度图表
实验一
Introduction to Huawei cloud micro certification examination
Cloudquery v1.2.0 release
August 14, 2020: what are the execution engines for data tasks?
image operating system windows cannot be used on this platform
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
Using JSON webtoken (JWT) to generate token in nodejs
Points to be considered when deleting mapping field of index in ES
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
About Devops seven misunderstandings, 99% of people have been hit!
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M