diff options
Diffstat (limited to 'src/pkg/runtime/proc.go')
| -rw-r--r-- | src/pkg/runtime/proc.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.go b/src/pkg/runtime/proc.go index 1ed6c26eba..de58daa130 100644 --- a/src/pkg/runtime/proc.go +++ b/src/pkg/runtime/proc.go @@ -6,6 +6,9 @@ package runtime import "unsafe" +// This is not mechanically generated +// so be very careful and refer to runtime.h +// for the definitive enum. const ( gStatusidle = iota gStatusRunnable @@ -14,6 +17,14 @@ const ( gStatusWaiting gStatusMoribundUnused gStatusDead + gStatusEnqueue + gStatusCopystack + gStatusScan = 0x1000 + gStatusScanRunnable = gStatusScan + gStatusRunnable + gStatusScanRunning = gStatusScan + gStatusRunning + gStatusScanSyscall = gStatusScan + gStatusSyscall + gStatusScanWaiting = gStatusScan + gStatusWaiting + gStatusScanEnqueue = gStatusScan + gStatusEnqueue ) var parkunlock_c byte @@ -24,12 +35,18 @@ func Gosched() { mcall(&gosched_m) } +func readgStatus(gp *g) uint32 { + //return atomic.LoadUint32(&gp.atomicstatus) // TODO: add bootstrap code to provide. + return gp.atomicstatus +} + // Puts the current goroutine into a waiting state and calls unlockf. // If unlockf returns false, the goroutine is resumed. func gopark(unlockf unsafe.Pointer, lock unsafe.Pointer, reason string) { mp := acquirem() gp := mp.curg - if gp.status != gStatusRunning { + status := readgStatus(gp) + if status != gStatusRunning && status != gStatusScanRunning { gothrow("gopark: bad g status") } mp.waitlock = lock |
