mirror of
https://github.com/golang/go
synced 2024-11-25 20:57:57 -07:00
runtime: fix LockOSThread
Fixes #6100. R=golang-dev, dave, bradfitz, rsc CC=golang-dev https://golang.org/cl/12703045
This commit is contained in:
parent
f9066fe1c0
commit
4961483e7d
@ -1871,8 +1871,12 @@ runtime·gomaxprocsfunc(int32 n)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lockOSThread is called by runtime.LockOSThread and runtime.lockOSThread below
|
||||||
|
// after they modify m->locked. Do not allow preemption during this call,
|
||||||
|
// or else the m might be different in this function than in the caller.
|
||||||
|
#pragma textflag NOSPLIT
|
||||||
static void
|
static void
|
||||||
LockOSThread(void)
|
lockOSThread(void)
|
||||||
{
|
{
|
||||||
m->lockedg = g;
|
m->lockedg = g;
|
||||||
g->lockedm = m;
|
g->lockedm = m;
|
||||||
@ -1882,18 +1886,23 @@ void
|
|||||||
runtime·LockOSThread(void)
|
runtime·LockOSThread(void)
|
||||||
{
|
{
|
||||||
m->locked |= LockExternal;
|
m->locked |= LockExternal;
|
||||||
LockOSThread();
|
lockOSThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·lockOSThread(void)
|
runtime·lockOSThread(void)
|
||||||
{
|
{
|
||||||
m->locked += LockInternal;
|
m->locked += LockInternal;
|
||||||
LockOSThread();
|
lockOSThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unlockOSThread is called by runtime.UnlockOSThread and runtime.unlockOSThread below
|
||||||
|
// after they update m->locked. Do not allow preemption during this call,
|
||||||
|
// or else the m might be in different in this function than in the caller.
|
||||||
|
#pragma textflag NOSPLIT
|
||||||
static void
|
static void
|
||||||
UnlockOSThread(void)
|
unlockOSThread(void)
|
||||||
{
|
{
|
||||||
if(m->locked != 0)
|
if(m->locked != 0)
|
||||||
return;
|
return;
|
||||||
@ -1905,7 +1914,7 @@ void
|
|||||||
runtime·UnlockOSThread(void)
|
runtime·UnlockOSThread(void)
|
||||||
{
|
{
|
||||||
m->locked &= ~LockExternal;
|
m->locked &= ~LockExternal;
|
||||||
UnlockOSThread();
|
unlockOSThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1914,7 +1923,7 @@ runtime·unlockOSThread(void)
|
|||||||
if(m->locked < LockInternal)
|
if(m->locked < LockInternal)
|
||||||
runtime·throw("runtime: internal error: misuse of lockOSThread/unlockOSThread");
|
runtime·throw("runtime: internal error: misuse of lockOSThread/unlockOSThread");
|
||||||
m->locked -= LockInternal;
|
m->locked -= LockInternal;
|
||||||
UnlockOSThread();
|
unlockOSThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user