[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140816215104.GA19006@dcvr.yhbt.net>
Date: Sat, 16 Aug 2014 21:51:04 +0000
From: Eric Wong <normalperson@...t.net>
To: Steven Stewart-Gallus <sstewartgallus00@...angara.bc.ca>
Cc: linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
mtk@...7.org
Subject: Re: Does anyone know when FUTEX_WAIT can fail with EAGAIN?
Steven Stewart-Gallus <sstewartgallus00@...angara.bc.ca> wrote:
> I'm trying to debug a hangup where my program loops with FUTEX_WAIT (actually
> FUTEX_WAIT_PRIVATE but same thing) endlessly erring out with EAGAIN. I would
> like to know if anyone on the mailing list knows when FUTEX_WAIT can fail with
> EAGAIN.
FUTEX_WAIT fails with EAGAIN if the value of *uaddr no longer matches
the expected val.
---
#include <linux/futex.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <errno.h>
int main(void) {
int op = FUTEX_WAIT;
int exp = 1;
int *addr = &exp;
int val = 1; /* XXX change this to anything else to get EAGAIN */
int rc = syscall(SYS_futex, addr, op, val, 0, 0, 0);
if (rc < 0 && errno == EAGAIN)
write(1, "EAGAIN\n", 7);
return 0;
}
---
I just encountered this myself yesterday while implementing futex-based
locks/condvars for Ruby:
https://bugs.ruby-lang.org/issues/10009#change-48372
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists