当前位置:网站首页>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
边栏推荐
- confd
- 打工人好物——磨炼钢铁意志就要这样高效的电脑
- A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
- [graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
- Detailed software engineering -- the necessary graphs in each stage
- 测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
- 如何使用甘特图图层和筛选器
- August 14, 2020: what are the execution engines for data tasks?
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
猜你喜欢
Novice guidance and event management system in game development
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
磁存储芯片STT-MRAM的特点
Zhou Jie: database system of East China Normal University
如何使用甘特图图层和筛选器
2020-08-17: how to solve data skew in detail?
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
打工人好物——磨炼钢铁意志就要这样高效的电脑
How does varhart xgantt represent working days on a calendar
随机推荐
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
Unexpected element.. required element
Composition of MRAM cache
PHP后门隐藏技巧
Logo design company, Nanjing
How to use Gantt chart layers and filters
8.Swarm创建维护和水平扩展Service
How to optimize the decoding performance of dynamsoft barcode reader
To solve the problem that the data interface is not updated after WPF binding set
2020-08-15: under what circumstances should data tasks be optimized?
如何才能快速正确的部署甘特图
.NETCore3.1+Vue.js打造的低代码工作流引擎
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
Git remote library rollback specified version
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
August 18, 2020: introduce Mr process?