Skip to content

Commit

Permalink
Update 2、Golang的协程调度器原理及GMP设计思想?.md
Browse files Browse the repository at this point in the history
修改场景7中,取全局队列数的公式
  • Loading branch information
frankxjkuang authored Feb 18, 2022
1 parent f9fcf1e commit fe1d0e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 2、Golang的协程调度器原理及GMP设计思想?.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ G2创建G8时,P1的本地队列未满,所以G8会被加入到P1的本地队
M2尝试从全局队列(简称“GQ”)取一批G放到P2的本地队列(函数:`findrunnable()`)。M2从全局队列取的G数量符合下面的公式:

```go
n = min(len(GQ)/GOMAXPROCS + 1, len(GQ/2))
n = min(len(GQ)/GOMAXPROCS + 1, len(GQ)/2)
```

至少从全局队列取1个g,但每次不要从全局队列移动太多的g到p本地队列,给其他p留点。这是**从全局队列到P本地队列的负载均衡**
Expand Down

0 comments on commit fe1d0e8

Please sign in to comment.