//
//go:nosplit
func readgstatus(gp *g) uint32 {
- return atomic.Load(&gp.atomicstatus)
+ return gp.atomicstatus.Load()
}
// The Gscanstatuses are acting like locks and this releases them.
_Gscansyscall,
_Gscanpreempted:
if newval == oldval&^_Gscan {
- success = atomic.Cas(&gp.atomicstatus, oldval, newval)
+ success = gp.atomicstatus.CompareAndSwap(oldval, newval)
}
}
if !success {
_Gwaiting,
_Gsyscall:
if newval == oldval|_Gscan {
- r := atomic.Cas(&gp.atomicstatus, oldval, newval)
+ r := gp.atomicstatus.CompareAndSwap(oldval, newval)
if r {
acquireLockRank(lockRankGscan)
}
// loop if gp->atomicstatus is in a scan state giving
// GC time to finish and change the state to oldval.
- for i := 0; !atomic.Cas(&gp.atomicstatus, oldval, newval); i++ {
- if oldval == _Gwaiting && gp.atomicstatus == _Grunnable {
+ for i := 0; !gp.atomicstatus.CompareAndSwap(oldval, newval); i++ {
+ if oldval == _Gwaiting && gp.atomicstatus.Load() == _Grunnable {
throw("casgstatus: waiting for Gwaiting but is Grunnable")
}
if i == 0 {
nextYield = nanotime() + yieldDelay
}
if nanotime() < nextYield {
- for x := 0; x < 10 && gp.atomicstatus != oldval; x++ {
+ for x := 0; x < 10 && gp.atomicstatus.Load() != oldval; x++ {
procyield(1)
}
} else {
if oldstatus != _Gwaiting && oldstatus != _Grunnable {
throw("copystack: bad status, not Gwaiting or Grunnable")
}
- if atomic.Cas(&gp.atomicstatus, oldstatus, _Gcopystack) {
+ if gp.atomicstatus.CompareAndSwap(oldstatus, _Gcopystack) {
return oldstatus
}
}
throw("bad g transition")
}
acquireLockRank(lockRankGscan)
- for !atomic.Cas(&gp.atomicstatus, _Grunning, _Gscan|_Gpreempted) {
+ for !gp.atomicstatus.CompareAndSwap(_Grunning, _Gscan|_Gpreempted) {
}
}
if old != _Gpreempted || new != _Gwaiting {
throw("bad g transition")
}
- return atomic.Cas(&gp.atomicstatus, _Gpreempted, _Gwaiting)
+ return gp.atomicstatus.CompareAndSwap(_Gpreempted, _Gwaiting)
}
// stopTheWorld stops all P's from executing goroutines, interrupting
# args = gdb.string_to_argv(arg)
vp = gdb.lookup_type('void').pointer()
for ptr in SliceValue(gdb.parse_and_eval("'runtime.allgs'")):
- if ptr['atomicstatus'] == G_DEAD:
+ if ptr['atomicstatus']['value'] == G_DEAD:
continue
s = ' '
if ptr['m']:
pc = ptr['sched']['pc'].cast(vp)
pc = pc_to_int(pc)
blk = gdb.block_for_pc(pc)
- status = int(ptr['atomicstatus'])
+ status = int(ptr['atomicstatus']['value'])
st = sts.get(status, "unknown(%d)" % status)
print(s, ptr['goid'], "{0:8s}".format(st), blk.function)
"""
vp = gdb.lookup_type('void').pointer()
for ptr in SliceValue(gdb.parse_and_eval("'runtime.allgs'")):
- if ptr['atomicstatus'] == G_DEAD:
+ if ptr['atomicstatus']['value'] == G_DEAD:
continue
if ptr['goid'] == goid:
break
return None, None
# Get the goroutine's saved state.
pc, sp = ptr['sched']['pc'], ptr['sched']['sp']
- status = ptr['atomicstatus']&~G_SCAN
+ status = ptr['atomicstatus']['value']&~G_SCAN
# Goroutine is not running nor in syscall, so use the info in goroutine
if status != G_RUNNING and status != G_SYSCALL:
return pc.cast(vp), sp.cast(vp)