if newval == oldval&^_Gscan {
success = atomic.Cas(&gp.atomicstatus, oldval, newval)
}
- case _Gscanenqueue:
- if newval == _Gwaiting {
- success = atomic.Cas(&gp.atomicstatus, oldval, newval)
- }
}
if !success {
print("runtime: casfrom_Gscanstatus failed gp=", gp, ", oldval=", hex(oldval), ", newval=", hex(newval), "\n")
func castogscanstatus(gp *g, oldval, newval uint32) bool {
switch oldval {
case _Grunnable,
+ _Grunning,
_Gwaiting,
_Gsyscall:
if newval == oldval|_Gscan {
return atomic.Cas(&gp.atomicstatus, oldval, newval)
}
- case _Grunning:
- if newval == _Gscanrunning || newval == _Gscanenqueue {
- return atomic.Cas(&gp.atomicstatus, oldval, newval)
- }
}
print("runtime: castogscanstatus oldval=", hex(oldval), " newval=", hex(newval), "\n")
throw("castogscanstatus")
_Gscanwaiting,
_Gscansyscall:
casfrom_Gscanstatus(gp, s, s&^_Gscan)
-
- // Scan is now completed.
- // Goroutine now needs to be made runnable.
- // We put it on the global run queue; ready blocks on the global scheduler lock.
- case _Gscanenqueue:
- casfrom_Gscanstatus(gp, _Gscanenqueue, _Gwaiting)
- if gp != getg().m.curg {
- throw("processing Gscanenqueue on wrong m")
- }
- dropg()
- ready(gp, 0)
}
}
_Gwaiting // 4
_Gmoribund_unused // 5 currently unused, but hardcoded in gdb scripts
_Gdead // 6
- _Genqueue // 7 Only the Gscanenqueue is used.
+ _Genqueue_unused // 7 currently unused
_Gcopystack // 8 in this state when newstack is moving the stack
// the following encode that the GC is scanning the stack and what to do when it is done
_Gscan = 0x1000 // atomicstatus&~Gscan = the non-scan state,
_Gscanwaiting = _Gscan + _Gwaiting // 0x1004 When scanning completes make it Gwaiting
// _Gscanmoribund_unused, // not possible
// _Gscandead, // not possible
- _Gscanenqueue = _Gscan + _Genqueue // When scanning completes make it Grunnable and put on runqueue
+ // _Gscanenqueue_unused // not possible
)
const (