Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 644 Bytes

File metadata and controls

44 lines (34 loc) · 644 Bytes

运行时死锁检查

TODO: 尚未开始写作

sched.nmidle:

//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:

func incidlelocked(v int32) {
	lock(&sched.lock)
	sched.nmidlelocked += v
	if v > 0 {
		checkdead()
	}
	unlock(&sched.lock)
}

许可

Go under the hood | CC-BY-NC-ND 4.0 & MIT © changkun