aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-08-13 22:37:04 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-08-13 22:37:04 +0400
commit4961483e7d8e0edf5211ab9f92aa010a6f74b59d (patch)
treeeca8e46a0fb94b4bb76e533a96ded06f26e2139b /src/pkg/runtime/proc.c
parentf9066fe1c0a7181242f77d8534e0b6e112c982a9 (diff)
downloadgo-4961483e7d8e0edf5211ab9f92aa010a6f74b59d.tar.xz
runtime: fix LockOSThread
Fixes #6100. R=golang-dev, dave, bradfitz, rsc CC=golang-dev https://golang.org/cl/12703045
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index bf941548fc..3b907e7fd1 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -1871,8 +1871,12 @@ runtime·gomaxprocsfunc(int32 n)
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
-LockOSThread(void)
+lockOSThread(void)
{
m->lockedg = g;
g->lockedm = m;
@@ -1882,18 +1886,23 @@ void
runtime·LockOSThread(void)
{
m->locked |= LockExternal;
- LockOSThread();
+ lockOSThread();
}
void
runtime·lockOSThread(void)
{
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
-UnlockOSThread(void)
+unlockOSThread(void)
{
if(m->locked != 0)
return;
@@ -1905,7 +1914,7 @@ void
runtime·UnlockOSThread(void)
{
m->locked &= ~LockExternal;
- UnlockOSThread();
+ unlockOSThread();
}
void
@@ -1914,7 +1923,7 @@ runtime·unlockOSThread(void)
if(m->locked < LockInternal)
runtime·throw("runtime: internal error: misuse of lockOSThread/unlockOSThread");
m->locked -= LockInternal;
- UnlockOSThread();
+ unlockOSThread();
}
bool