diff options
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(); |