mirror of
https://github.com/golang/go
synced 2024-11-19 08:54:47 -07:00
runtime: convert Gosched to Go
LGTM=rlh, khr R=golang-codereviews, rlh, bradfitz, khr CC=golang-codereviews, rsc https://golang.org/cl/127490043
This commit is contained in:
parent
53056c37c2
commit
5d40742728
@ -73,10 +73,6 @@ of the run-time system.
|
|||||||
*/
|
*/
|
||||||
package runtime
|
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 terminates the goroutine that calls it. No other goroutine is affected.
|
||||||
// Goexit runs all deferred calls before terminating the goroutine.
|
// Goexit runs all deferred calls before terminating the goroutine.
|
||||||
//
|
//
|
||||||
|
@ -1449,15 +1449,15 @@ park0(G *gp)
|
|||||||
void
|
void
|
||||||
runtime·gosched(void)
|
runtime·gosched(void)
|
||||||
{
|
{
|
||||||
if(g->status != Grunning)
|
runtime·mcall(runtime·gosched_m);
|
||||||
runtime·throw("bad g status");
|
|
||||||
runtime·mcall(runtime·gosched0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// runtime·gosched continuation on g0.
|
// runtime·gosched continuation on g0.
|
||||||
void
|
void
|
||||||
runtime·gosched0(G *gp)
|
runtime·gosched_m(G *gp)
|
||||||
{
|
{
|
||||||
|
if(gp->status != Grunning)
|
||||||
|
runtime·throw("bad g status");
|
||||||
gp->status = Grunnable;
|
gp->status = Grunnable;
|
||||||
dropg();
|
dropg();
|
||||||
runtime·lock(&runtime·sched.lock);
|
runtime·lock(&runtime·sched.lock);
|
||||||
@ -2055,12 +2055,6 @@ runtime·Breakpoint(void)
|
|||||||
runtime·breakpoint();
|
runtime·breakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
runtime·Gosched(void)
|
|
||||||
{
|
|
||||||
runtime·gosched();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implementation of runtime.GOMAXPROCS.
|
// Implementation of runtime.GOMAXPROCS.
|
||||||
// delete when scheduler is even stronger
|
// delete when scheduler is even stronger
|
||||||
int32
|
int32
|
||||||
|
11
src/pkg/runtime/proc.go
Normal file
11
src/pkg/runtime/proc.go
Normal file
@ -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)
|
||||||
|
}
|
@ -919,7 +919,7 @@ void runtime·newextram(void);
|
|||||||
void runtime·exit(int32);
|
void runtime·exit(int32);
|
||||||
void runtime·breakpoint(void);
|
void runtime·breakpoint(void);
|
||||||
void runtime·gosched(void);
|
void runtime·gosched(void);
|
||||||
void runtime·gosched0(G*);
|
void runtime·gosched_m(G*);
|
||||||
void runtime·schedtrace(bool);
|
void runtime·schedtrace(bool);
|
||||||
void runtime·park(bool(*)(G*, void*), void*, int8*);
|
void runtime·park(bool(*)(G*, void*), void*, int8*);
|
||||||
void runtime·parkunlock(Lock*, int8*);
|
void runtime·parkunlock(Lock*, int8*);
|
||||||
|
@ -903,7 +903,7 @@ runtime·newstack(void)
|
|||||||
}
|
}
|
||||||
// Act like goroutine called runtime.Gosched.
|
// Act like goroutine called runtime.Gosched.
|
||||||
gp->status = oldstatus;
|
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
|
// If every frame on the top segment is copyable, allocate a bigger segment
|
||||||
|
@ -68,7 +68,8 @@ var (
|
|||||||
setFinalizer_m,
|
setFinalizer_m,
|
||||||
markallocated_m,
|
markallocated_m,
|
||||||
unrollgcprog_m,
|
unrollgcprog_m,
|
||||||
unrollgcproginplace_m mFunction
|
unrollgcproginplace_m,
|
||||||
|
gosched_m mFunction
|
||||||
)
|
)
|
||||||
|
|
||||||
// memclr clears n bytes starting at ptr.
|
// memclr clears n bytes starting at ptr.
|
||||||
|
Loading…
Reference in New Issue
Block a user