Commit 8ba5c559 authored by Russ Cox's avatar Russ Cox

runtime: work around Linux kernel bug in futex

Fixes #420.

R=r
CC=golang-dev
https://golang.org/cl/218065
parent 5c2197ac
...@@ -42,20 +42,12 @@ static Timespec longtime = ...@@ -42,20 +42,12 @@ static Timespec longtime =
static void static void
futexsleep(uint32 *addr, uint32 val) futexsleep(uint32 *addr, uint32 val)
{ {
int32 ret; // Some Linux kernels have a bug where futex of
// FUTEX_WAIT returns an internal error code
ret = futex(addr, FUTEX_WAIT, val, &longtime, nil, 0); // as an errno. Libpthread ignores the return value
if(ret >= 0 || ret == -EAGAIN || ret == -EINTR) // here, and so can we: as it says a few lines up,
return; // spurious wakeups are allowed.
futex(addr, FUTEX_WAIT, val, &longtime, nil, 0);
prints("futexsleep addr=");
·printpointer(addr);
prints(" val=");
·printint(val);
prints(" returned ");
·printint(ret);
prints("\n");
*(int32*)0x1005 = 0x1005;
} }
// If any procs are sleeping on addr, wake up at least one. // If any procs are sleeping on addr, wake up at least one.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment