From: Eric Wong <normalperson@yhbt.net>
To: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, mtk@man7.org
Subject: Re: Does anyone know when FUTEX_WAIT can fail with EAGAIN?
Date: Sat, 16 Aug 2014 21:51:04 +0000 [thread overview]
Message-ID: <20140816215104.GA19006@dcvr.yhbt.net> (raw)
In-Reply-To: <fb82d1d46d8f.53d8186c@langara.bc.ca>
Steven Stewart-Gallus <sstewartgallus00@mylangara.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
next prev parent reply other threads:[~2014-08-16 21:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 21:55 Does anyone know when FUTEX_WAIT can fail with EAGAIN? Steven Stewart-Gallus
2014-08-16 21:51 ` Eric Wong [this message]
[not found] ` <fb82d1d46d8f.53d8186c-BTv7Ps/Sm75C8prJL3GQQw@public.gmane.org>
2014-08-17 15:48 ` Davidlohr Bueso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140816215104.GA19006@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk@man7.org \
--cc=sstewartgallus00@mylangara.bc.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox