当前位置:网站首页>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
边栏推荐
- Qt音视频开发46-视频传输UDP版
- 三步轻松理解Kerberos协议
- A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
- JVM class loading mechanism
- 小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
- PHP backdoor hiding skills
- python3操作gitlab
- Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
- Composition of MRAM cache
- Stm32f030f4p6 compatible with smart micro mm32f031f4p6
猜你喜欢
打工人好物——磨炼钢铁意志就要这样高效的电脑
Exclusive interview with Alibaba cloud database for 2020 PostgreSQL Asia Conference: Zeng Wenjing
confd
Utility class functions (continuous update)
Bluetooth broadcast chip for Shanghai giant micro
如何创建交互式内核密度图表
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
Qt音视频开发46-视频传输UDP版
Novice guidance and event management system in game development
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
随机推荐
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
How does varhart xgantt represent working days on a calendar
Image processing toolkit imagexpresshow to view events
Cloudquery v1.2.0 release
Mongo user rights login instruction
Utility class functions (continuous update)
Stickinengine architecture 12 communication protocol
How to deploy Gantt chart quickly and correctly
#JVM 类加载机制
8.Swarm创建维护和水平扩展Service
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
2020 database technology conference helps technology upgrade
Git remote library rollback specified version
Google browser realizes video playback acceleration function
ado.net and asp.net The relationship between
PHP backdoor hiding skills
南京标识标牌设计制作,导视VI系统设计
Qt音视频开发46-视频传输UDP版
vue3 新特性
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud