Source File
preempt.go
Belonging Package
runtime
package runtime
import (
)
type suspendGState struct {
g *g
func ( *g) suspendGState {
throw("suspendG from non-preemptible goroutine")
}
const = 10 * 1000
var int64
:= false
var *m
var uint32
var int64
for := 0; ; ++ {
switch := readgstatus(); {
default:
break
}
dumpgstatus()
throw("invalid g status")
return suspendGState{dead: true}
if !casGFromPreempted(, _Gpreempted, _Gwaiting) {
break
}
if !castogscanstatus(, , |_Gscan) {
break
}
.preemptStop = false
.preempt = false
.stackguard0 = .stack.lo + _StackGuard
return suspendGState{g: , stopped: }
if .preemptStop && .preempt && .stackguard0 == stackPreempt && == .m && atomic.Load(&.preemptGen) == {
break
}
if !castogscanstatus(, _Grunning, _Gscanrunning) {
break
}
.preemptStop = true
.preempt = true
.stackguard0 = stackPreempt
:= .m
:= atomic.Load(&.preemptGen)
:= != || !=
=
=
casfrom_Gscanstatus(, _Gscanrunning, _Grunning)
func ( suspendGState) {
return
}
:= .g
switch := readgstatus(); {
default:
dumpgstatus()
throw("unexpected g status")
case _Grunnable | _Gscan,
_Gwaiting | _Gscan,
_Gsyscall | _Gscan:
casfrom_Gscanstatus(, , &^_Gscan)
}
func ()
func () {
:= getg()
.asyncSafePoint = true
if .preemptStop {
mcall(preemptPark)
} else {
mcall(gopreempt_m)
}
.asyncSafePoint = false
}
var asyncPreemptStack = ^uintptr(0)
func () {
:= findfunc(funcPC(asyncPreempt))
:= funcMaxSPDelta()
= findfunc(funcPC(asyncPreempt2))
asyncPreemptStack = uintptr() + 8*sys.PtrSize
print("runtime: asyncPreemptStack=", asyncPreemptStack, "\n")
throw("async stack too large")
}
}
if .p == 0 || !canPreemptM() {
return false, 0
}
:= findfunc()
return false, 0
}
return false, 0
}
, := pcdatavalue2(, _PCDATA_UnsafePoint, )
return false, 0
}
return false, 0
}
:= funcname()
if := funcdata(, _FUNCDATA_InlTree); != nil {
:= (*[1 << 20]inlinedCall)()
:= pcdatavalue(, _PCDATA_InlTreeIndex, , nil)
if >= 0 {
= funcnameFromNameoff(, [].func_)
}
}
if hasPrefix(, "runtime.") ||
hasPrefix(, "runtime/internal/") ||
return false, 0
}
switch {
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |