mirror of
https://github.com/golang/go
synced 2024-11-16 19:14:43 -07:00
runtime: avoid receiving preemotion signal while exec'ing
The iOS kernel has the same problem as the macOS kernel. Extend the workaround of #41702 (CL 262438 and CL 262817) to iOS. Updates #35851. Change-Id: I7ccec00dc96643c08c5be8b385394856d0fa0f64 Reviewed-on: https://go-review.googlesource.com/c/go/+/275293 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7358064508
commit
21cfadf0dc
@ -1363,7 +1363,7 @@ found:
|
|||||||
checkdead()
|
checkdead()
|
||||||
unlock(&sched.lock)
|
unlock(&sched.lock)
|
||||||
|
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
// Make sure pendingPreemptSignals is correct when an M exits.
|
// Make sure pendingPreemptSignals is correct when an M exits.
|
||||||
// For #41702.
|
// For #41702.
|
||||||
if atomic.Load(&m.signalPending) != 0 {
|
if atomic.Load(&m.signalPending) != 0 {
|
||||||
@ -3852,7 +3852,7 @@ func syscall_runtime_BeforeExec() {
|
|||||||
|
|
||||||
// On Darwin, wait for all pending preemption signals to
|
// On Darwin, wait for all pending preemption signals to
|
||||||
// be received. See issue #41702.
|
// be received. See issue #41702.
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
for int32(atomic.Load(&pendingPreemptSignals)) > 0 {
|
for int32(atomic.Load(&pendingPreemptSignals)) > 0 {
|
||||||
osyield()
|
osyield()
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ func doSigPreempt(gp *g, ctxt *sigctxt) {
|
|||||||
atomic.Xadd(&gp.m.preemptGen, 1)
|
atomic.Xadd(&gp.m.preemptGen, 1)
|
||||||
atomic.Store(&gp.m.signalPending, 0)
|
atomic.Store(&gp.m.signalPending, 0)
|
||||||
|
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
atomic.Xadd(&pendingPreemptSignals, -1)
|
atomic.Xadd(&pendingPreemptSignals, -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,12 +352,12 @@ const preemptMSupported = true
|
|||||||
func preemptM(mp *m) {
|
func preemptM(mp *m) {
|
||||||
// On Darwin, don't try to preempt threads during exec.
|
// On Darwin, don't try to preempt threads during exec.
|
||||||
// Issue #41702.
|
// Issue #41702.
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
execLock.rlock()
|
execLock.rlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if atomic.Cas(&mp.signalPending, 0, 1) {
|
if atomic.Cas(&mp.signalPending, 0, 1) {
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
atomic.Xadd(&pendingPreemptSignals, 1)
|
atomic.Xadd(&pendingPreemptSignals, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ func preemptM(mp *m) {
|
|||||||
signalM(mp, sigPreempt)
|
signalM(mp, sigPreempt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
execLock.runlock()
|
execLock.runlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
|
|||||||
// no non-Go signal handler for sigPreempt.
|
// no non-Go signal handler for sigPreempt.
|
||||||
// The default behavior for sigPreempt is to ignore
|
// The default behavior for sigPreempt is to ignore
|
||||||
// the signal, so badsignal will be a no-op anyway.
|
// the signal, so badsignal will be a no-op anyway.
|
||||||
if GOOS == "darwin" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
atomic.Xadd(&pendingPreemptSignals, -1)
|
atomic.Xadd(&pendingPreemptSignals, -1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user