5

深入理解 Go | 调度:GMP 模型(第一部分)

 2 years ago
source link: https://ictar.github.io/2020/04/13/dive-into-go-schedule-gpm-part1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

深入理解 Go | 调度:GMP 模型(第一部分)

发表于

2020-04-13 更新于 2021-01-26

阅读次数: 33 Disqus: 1 Comment

以下基于 Go 1.14

Golang 中的调度是基于 GMP 模型来实现的: * G:表示 Goroutine,一个待执行的任务。 * 它对于 Go 运行时调度可以看做线程对于操作系统调度 * 在 Go 语言中使用 runtime.g 结构表示 * M:表示操作系统线程,由操作系统调度以及管理 * 调度器最多可以创建 10000 个线程,最多只会有 GOMAXPROCS 个活跃活跃线程 * 在 Go 语言中使用 runtime.m 结构表示 * P:表示处理器 * Go 程序的处理器数量一定是 GOMAXPROCS 个,在调度器启动的时候就会创建 * 在 Go 语言中使用 runtime.p 结构表示

一些全局变量说明:

附:数据结构

请言小午吃个甜筒~~

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK