diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/runtime/lock_futex.c | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-upstream/1.3.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/runtime/lock_futex.c')
-rw-r--r-- | src/pkg/runtime/lock_futex.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pkg/runtime/lock_futex.c b/src/pkg/runtime/lock_futex.c index e6e9be923..c16ac905d 100644 --- a/src/pkg/runtime/lock_futex.c +++ b/src/pkg/runtime/lock_futex.c @@ -130,8 +130,11 @@ runtime·notesleep(Note *n) { if(g != m->g0) runtime·throw("notesleep not on g0"); - while(runtime·atomicload((uint32*)&n->key) == 0) + while(runtime·atomicload((uint32*)&n->key) == 0) { + m->blocked = true; runtime·futexsleep((uint32*)&n->key, 0, -1); + m->blocked = false; + } } #pragma textflag NOSPLIT @@ -143,8 +146,11 @@ notetsleep(Note *n, int64 ns, int64 deadline, int64 now) // does not count against our nosplit stack sequence. if(ns < 0) { - while(runtime·atomicload((uint32*)&n->key) == 0) + while(runtime·atomicload((uint32*)&n->key) == 0) { + m->blocked = true; runtime·futexsleep((uint32*)&n->key, 0, -1); + m->blocked = false; + } return true; } @@ -153,7 +159,9 @@ notetsleep(Note *n, int64 ns, int64 deadline, int64 now) deadline = runtime·nanotime() + ns; for(;;) { + m->blocked = true; runtime·futexsleep((uint32*)&n->key, 0, ns); + m->blocked = false; if(runtime·atomicload((uint32*)&n->key) != 0) break; now = runtime·nanotime(); |