]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert Gosched to Go
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 19 Aug 2014 07:49:59 +0000 (11:49 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 19 Aug 2014 07:49:59 +0000 (11:49 +0400)
LGTM=rlh, khr
R=golang-codereviews, rlh, bradfitz, khr
CC=golang-codereviews, rsc
https://golang.org/cl/127490043

src/pkg/runtime/extern.go
src/pkg/runtime/proc.c
src/pkg/runtime/proc.go [new file with mode: 0644]
src/pkg/runtime/runtime.h
src/pkg/runtime/stack.c
src/pkg/runtime/stubs.go

index 57f09aaf7d4ef54882b2fb10786b236465483c97..533cb431b9276652691e24ec459d0c816cac5d2b 100644 (file)
@@ -73,10 +73,6 @@ of the run-time system.
 */
 package runtime
 
-// Gosched yields the processor, allowing other goroutines to run.  It does not
-// suspend the current goroutine, so execution resumes automatically.
-func Gosched()
-
 // Goexit terminates the goroutine that calls it.  No other goroutine is affected.
 // Goexit runs all deferred calls before terminating the goroutine.
 //
index a3e0f4bc52bd661e62b6f9ad203a3d6e44f15e5c..2510a421a86a1dda197076d780ca4d72d8a6ae6b 100644 (file)
@@ -1449,15 +1449,15 @@ park0(G *gp)
 void
 runtime·gosched(void)
 {
-       if(g->status != Grunning)
-               runtime·throw("bad g status");
-       runtime·mcall(runtime·gosched0);
+       runtime·mcall(runtime·gosched_m);
 }
 
 // runtime·gosched continuation on g0.
 void
-runtime·gosched0(G *gp)
+runtime·gosched_m(G *gp)
 {
+       if(gp->status != Grunning)
+               runtime·throw("bad g status");
        gp->status = Grunnable;
        dropg();
        runtime·lock(&runtime·sched.lock);
@@ -2055,12 +2055,6 @@ runtime·Breakpoint(void)
        runtime·breakpoint();
 }
 
-void
-runtime·Gosched(void)
-{
-       runtime·gosched();
-}
-
 // Implementation of runtime.GOMAXPROCS.
 // delete when scheduler is even stronger
 int32
diff --git a/src/pkg/runtime/proc.go b/src/pkg/runtime/proc.go
new file mode 100644 (file)
index 0000000..1b586e8
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+// Gosched yields the processor, allowing other goroutines to run.  It does not
+// suspend the current goroutine, so execution resumes automatically.
+func Gosched() {
+       mcall(&gosched_m)
+}
index 0aeba39da8c7721694b8bbee5a6ace8d7d03f917..0dc60b286b30fe594631c393431466045685976e 100644 (file)
@@ -919,7 +919,7 @@ void        runtime·newextram(void);
 void   runtime·exit(int32);
 void   runtime·breakpoint(void);
 void   runtime·gosched(void);
-void   runtime·gosched0(G*);
+void   runtime·gosched_m(G*);
 void   runtime·schedtrace(bool);
 void   runtime·park(bool(*)(G*, void*), void*, int8*);
 void   runtime·parkunlock(Lock*, int8*);
index 3bd96ff31437bf9ccd8409692273c15e58034ade..f7d41f44d41a9ca24ece5794fd272b41263fa338 100644 (file)
@@ -903,7 +903,7 @@ runtime·newstack(void)
                }
                // Act like goroutine called runtime.Gosched.
                gp->status = oldstatus;
-               runtime·gosched0(gp);  // never return
+               runtime·gosched_m(gp); // never return
        }
 
        // If every frame on the top segment is copyable, allocate a bigger segment
index a4ef9d3d55cbd40c5d9e2ed6f8d70fd6e11843e2..39244ef9df212218da46319cc8770f8373095602 100644 (file)
@@ -68,7 +68,8 @@ var (
        setFinalizer_m,
        markallocated_m,
        unrollgcprog_m,
-       unrollgcproginplace_m mFunction
+       unrollgcproginplace_m,
+       gosched_m mFunction
 )
 
 // memclr clears n bytes starting at ptr.