diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-15 16:48:41 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-15 16:48:41 +0400 |
| commit | 764bb36ea2be3fd9c04a0a485524a75241c21b8a (patch) | |
| tree | 98d49f6612f28a0d237687179b9f4ac7acc271fb /src/pkg/runtime/lock_futex.c | |
| parent | e69012ce2a366e54bc86cd17f2fb1d73fc567a89 (diff) | |
| download | go-764bb36ea2be3fd9c04a0a485524a75241c21b8a.tar.xz | |
runtime: unset m->locks after actual lock unlock
This is needed for preemptive scheduler,
it will preempt only when m->locks==0,
and we do not want to be preempted while
we have not completely unlocked the lock.
R=golang-dev, khr, iant
CC=golang-dev
https://golang.org/cl/9196047
Diffstat (limited to 'src/pkg/runtime/lock_futex.c')
| -rw-r--r-- | src/pkg/runtime/lock_futex.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pkg/runtime/lock_futex.c b/src/pkg/runtime/lock_futex.c index 3c2ef4ede0..d20b63c329 100644 --- a/src/pkg/runtime/lock_futex.c +++ b/src/pkg/runtime/lock_futex.c @@ -91,14 +91,14 @@ runtime·unlock(Lock *l) { uint32 v; - if(--m->locks < 0) - runtime·throw("runtime·unlock: lock count"); - v = runtime·xchg((uint32*)&l->key, MUTEX_UNLOCKED); if(v == MUTEX_UNLOCKED) runtime·throw("unlock of unlocked lock"); if(v == MUTEX_SLEEPING) runtime·futexwakeup((uint32*)&l->key, 1); + + if(--m->locks < 0) + runtime·throw("runtime·unlock: lock count"); } // One-time notifications. |
