当前位置:网站首页>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
边栏推荐
- Using JSON webtoken (JWT) to generate token in nodejs
- To solve the problem that the data interface is not updated after WPF binding set
- Erd-online free online database modeling tool
- How to manage the authority of database account?
- 轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
- Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
- 测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
- 实验一
- JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
- 如何才能快速正确的部署甘特图
猜你喜欢
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
LEADTOOLS如何检测,读取和写入条形码
8. Swarm creates maintenance and horizontal extension service
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
7.Swarm搭建集群
Characteristics of magnetic memory chip STT-MRAM
如何使用甘特图图层和筛选器
Logo design company, Nanjing
随机推荐
September 3, 2020: naked writing algorithm: loop matrix traversal.
To solve the problem that the data interface is not updated after WPF binding set
Application of UHF RFID medical blood management system
PHP后门隐藏技巧
#JVM 类加载机制
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
[elastic search engine]
三步轻松理解Kerberos协议
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
Using JSON webtoken (JWT) to generate token in nodejs
Utility class functions (continuous update)
The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
Common mathematical basic formulas of recursive and backtracking algorithms
Configuration of AP hotspot on xunwei-imx6ull development board
The memorandum model of behavior model
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
Summary of common SQL statements
vue3 新特性