当前位置:网站首页>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
边栏推荐
- Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
- Common mathematical basic formulas of recursive and backtracking algorithms
- Nonvolatile MRAM memory used in all levels of cache
- August 18, 2020: introduce Mr process?
- The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
- 2020-08-15: under what circumstances should data tasks be optimized?
- Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
- Jenkins installation and deployment process
- How to add modules to nginx image?
- Stm32f030f4p6 compatible with smart micro mm32f031f4p6
猜你喜欢
Nanjing logo design and production, guide VI system design
谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
List to map (split the list according to the key, and the value of the same key is a list)
消防器材RFID固定资产管理系统
Gantt chart grouping activities tutorial
Points to be considered when deleting mapping field of index in ES
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
8. Swarm creates maintenance and horizontal extension service
2020-08-19: what mechanism does TCP ensure reliability?
随机推荐
[learning] interface test case writing and testing concerns
Two dimensional code location and alarm system of Expressway
ImageMagick - add watermark
How to manage the authority of database account?
The Interpreter pattern of behavior pattern
VARCHART XGantt入门教程
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
FreeSWITCH视频会议“标准”解决方案
Nonvolatile MRAM memory used in all levels of cache
[doodling the footprints of Internet of things] Introduction to Internet of things
Mobile pixel adaptation scheme
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
Utility class functions (continuous update)
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
图像处理工具包ImagXpress使用教程,如何查看事件
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
2020年新规,微信封号怎么快速解除?