aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/preempt.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2019-10-16 19:10:06 -0400
committerAustin Clements <austin@google.com>2019-11-02 21:51:14 +0000
commita3ffb0d9eb948409c0898c6b1803401c9bc68ed4 (patch)
treeb5d9aa8849a61c16b76d4a3298cdfee195951bbe /src/runtime/preempt.go
parent2d031dc559a720ec2c1939848a2e5de2782acd5a (diff)
downloadgo-a3ffb0d9eb948409c0898c6b1803401c9bc68ed4.tar.gz
go-a3ffb0d9eb948409c0898c6b1803401c9bc68ed4.zip
runtime: asynchronous preemption function for x86
This adds asynchronous preemption function for amd64 and 386. These functions spill and restore all register state that can be used by user Go code. For the moment we stub out the other arches. For #10958, #24543. Change-Id: I6f93fabe9875f4834922a5712362e79045c00aca Reviewed-on: https://go-review.googlesource.com/c/go/+/201759 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/preempt.go')
-rw-r--r--src/runtime/preempt.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go
index 96eaa3488b..57ec493b8d 100644
--- a/src/runtime/preempt.go
+++ b/src/runtime/preempt.go
@@ -232,3 +232,18 @@ func resumeG(state suspendGState) {
func canPreemptM(mp *m) bool {
return mp.locks == 0 && mp.mallocing == 0 && mp.preemptoff == "" && mp.p.ptr().status == _Prunning
}
+
+//go:generate go run mkpreempt.go
+
+// asyncPreempt saves all user registers and calls asyncPreempt2.
+//
+// When stack scanning encounters an asyncPreempt frame, it scans that
+// frame and its parent frame conservatively.
+//
+// asyncPreempt is implemented in assembly.
+func asyncPreempt()
+
+//go:nosplit
+func asyncPreempt2() {
+ // TODO: Enter scheduler
+}