confuse about wakep?

59 views
Skip to first unread message

xie cui

unread,
Feb 23, 2021, 8:15:42 AM2/23/21
to golang-nuts
https://github.com/golang/go/blob/master/src/runtime/proc.go#L2441
why not  change to if !atomic.Cas(&sched.nmspinning, 0, 1),  it seems check sched.nmspinning no zero is unneccessary in logic,
i am not sure, i guess it's about performence issue?

Ian Lance Taylor

unread,
Feb 23, 2021, 11:25:39 PM2/23/21
to xie cui, golang-nuts
An atomic load is faster than an atomic compare-and-swap. In
particular, on amd64, an atomic load is just an ordinary load
instruction.

Ian
Reply all
Reply to author
Forward
0 new messages