11.1 运行时死锁检查

11.1 运行时死锁检查

TODO: 请不要阅读此小节,内容编排中

sched.nmidle:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
//go:nowritebarrierrec
func mput(mp *m) {
	mp.schedlink = sched.midle
	sched.midle.set(mp)
	sched.nmidle++
	checkdead()
}
//go:nowritebarrierrec
func mget() *m {
	mp := sched.midle.ptr()
	if mp != nil {
		sched.midle = mp.schedlink
		sched.nmidle--
	}
	return mp
}

sched.nmidlelocked:

1
2
3
4
5
6
7
8
func incidlelocked(v int32) {
	lock(&sched.lock)
	sched.nmidlelocked += v
	if v > 0 {
		checkdead()
	}
	unlock(&sched.lock)
}