P destroy的代码注释不够准确
luckyxiaoqiang opened this issue · comments
luckyxiaoqiang commented
实际描述
- 文件路径:book/zh-cn/part2runtime/ch06sched/mpg.md
- 原文段落:
// 释放未使用的 P,一般情况下不会执行这段代码
func (pp *p) destroy() {
// 将所有 runnable Goroutine 移动至全局队列
for pp.runqhead != pp.runqtail {
// 从本地队列中 pop
pp.runqtail--
gp := pp.runq[pp.runqtail%uint32(len(pp.runq))].ptr()
// push 到全局队列中
globrunqputhead(gp)
}
if pp.runnext != 0 {
globrunqputhead(pp.runnext.ptr())
pp.runnext = 0
}
(...)
// 将当前 P 的 G 复链转移到全局
gfpurge(pp)
(...)
pp.status = _Pdead
}
预期描述
// 释放未使用的 P,一般情况下不会执行这段代码
func (pp *p) destroy() {
// 将所有 runnable Goroutine 移动至全局队列
for pp.runqhead != pp.runqtail {
// 从本地队列中 pop
pp.runqtail--
gp := pp.runq[pp.runqtail%uint32(len(pp.runq))].ptr()
// push 到全局队列中
globrunqputhead(gp)
}
if pp.runnext != 0 {
globrunqputhead(pp.runnext.ptr())
pp.runnext = 0
}
(...)
// 将当前 P 的空闲的 G 复链转移到全局
gfpurge(pp)
(...)
pp.status = _Pdead
}