public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/17168] New: Can GLibc expose futex now?
@ 2014-07-17  4:44 sstewartgallus00 at mylangara dot bc.ca
  2014-07-17  4:57 ` [Bug libc/17168] " sstewartgallus00 at mylangara dot bc.ca
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sstewartgallus00 at mylangara dot bc.ca @ 2014-07-17  4:44 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17168

            Bug ID: 17168
           Summary: Can GLibc expose futex now?
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: sstewartgallus00 at mylangara dot bc.ca
                CC: drepper.fsp at gmail dot com

Most application writers should use standard pthread synchronization
functionality and not use low level functionality instead.  However,
certain performance concerned programmers might want to use futexes
directly.  Unfortunately, as FUTEX_WAIT is a blocking system call this
leaves a critical piece of functionality unimplemented and missing.
In the past, one could have used FUTEX_FD to wait on memory locations
to change asynchronously (although it would have been racy).  However,
FUTEX_FD is not supported anymore on Linux (as it is racy).  Now, the
only choice to use FUTEX_WAIT asynchronously is to use multiple
threads and cancel the thread waiting on the memory location to
change.  Except one can't as futex is not exposed by GLibc and I do
not want to try reimplementing pthread_cancel myself which might be
seriously difficult.  Taking the five seconds to wrap the futex calls
with the syscall function is not a problem but I can't use futex
asynchronously without support from GLibc.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/17168] Can GLibc expose futex now?
  2014-07-17  4:44 [Bug libc/17168] New: Can GLibc expose futex now? sstewartgallus00 at mylangara dot bc.ca
@ 2014-07-17  4:57 ` sstewartgallus00 at mylangara dot bc.ca
  2014-07-19  1:10 ` sstewartgallus00 at mylangara dot bc.ca
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sstewartgallus00 at mylangara dot bc.ca @ 2014-07-17  4:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17168

--- Comment #1 from Steven Stewart-Gallus <sstewartgallus00 at mylangara dot bc.ca> ---
This really isn't a huge problem because I can use timeouts and eventfds
instead for most purposes but it is a bit annoying.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/17168] Can GLibc expose futex now?
  2014-07-17  4:44 [Bug libc/17168] New: Can GLibc expose futex now? sstewartgallus00 at mylangara dot bc.ca
  2014-07-17  4:57 ` [Bug libc/17168] " sstewartgallus00 at mylangara dot bc.ca
@ 2014-07-19  1:10 ` sstewartgallus00 at mylangara dot bc.ca
  2014-07-19 18:34 ` sstewartgallus00 at mylangara dot bc.ca
  2014-07-19 18:55 ` bugdal at aerifal dot cx
  3 siblings, 0 replies; 5+ messages in thread
From: sstewartgallus00 at mylangara dot bc.ca @ 2014-07-19  1:10 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17168

--- Comment #2 from Steven Stewart-Gallus <sstewartgallus00 at mylangara dot bc.ca> ---
I'm confused, in the source in nptl/nptl-init.c the signal handler is
not set with the flag for the SA_RESTART and so I should be able to
simply handle pthread_cancel by waiting for EINTR and then using
pthread_testcancel? However, pthread_cancel only seems to send the
signal when asynchronous cancels are enabled and not for deferred
cancels?

The source:

  struct sigaction sa;
  sa.sa_sigaction = sigcancel_handler;
  sa.sa_flags = SA_SIGINFO;
  __sigemptyset (&sa.sa_mask);

  (void) __libc_sigaction (SIGCANCEL, &sa, NULL);

The possible workaround:

static errno_t futex_wait(int *uaddr, int val, struct timespec const *timeout)
{
    int xx = syscall(__NR_futex, (intptr_t)uaddr, (intptr_t)FUTEX_WAIT,
                     (intptr_t)val,
                     (intptr_t)timeout);
    if (xx < 0) {
        errno_t errnum = errno;
        if (EINTR == errnum) {
            pthread_testcancel();
        }
        return errnum;
    }

    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/17168] Can GLibc expose futex now?
  2014-07-17  4:44 [Bug libc/17168] New: Can GLibc expose futex now? sstewartgallus00 at mylangara dot bc.ca
  2014-07-17  4:57 ` [Bug libc/17168] " sstewartgallus00 at mylangara dot bc.ca
  2014-07-19  1:10 ` sstewartgallus00 at mylangara dot bc.ca
@ 2014-07-19 18:34 ` sstewartgallus00 at mylangara dot bc.ca
  2014-07-19 18:55 ` bugdal at aerifal dot cx
  3 siblings, 0 replies; 5+ messages in thread
From: sstewartgallus00 at mylangara dot bc.ca @ 2014-07-19 18:34 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17168

--- Comment #3 from Steven Stewart-Gallus <sstewartgallus00 at mylangara dot bc.ca> ---
Note that I could set the cancellation state to asynchronous and
synchronous back again but that'd have the same problems as with
https://sourceware.org/bugzilla/show_bug.cgi?id=12683 . In particular,
a FUTEX_WAIT could consume a notification but not act on it. As well,
someone could jump out of a signal handler and leave the cancellation
state set to asynchronous.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/17168] Can GLibc expose futex now?
  2014-07-17  4:44 [Bug libc/17168] New: Can GLibc expose futex now? sstewartgallus00 at mylangara dot bc.ca
                   ` (2 preceding siblings ...)
  2014-07-19 18:34 ` sstewartgallus00 at mylangara dot bc.ca
@ 2014-07-19 18:55 ` bugdal at aerifal dot cx
  3 siblings, 0 replies; 5+ messages in thread
From: bugdal at aerifal dot cx @ 2014-07-19 18:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17168

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugdal at aerifal dot cx
         Resolution|---                         |DUPLICATE

--- Comment #4 from Rich Felker <bugdal at aerifal dot cx> ---
This seems to be a request for a feature for which there is already an open
request, issue #9712.

*** This bug has been marked as a duplicate of bug 9712 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-19 18:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17  4:44 [Bug libc/17168] New: Can GLibc expose futex now? sstewartgallus00 at mylangara dot bc.ca
2014-07-17  4:57 ` [Bug libc/17168] " sstewartgallus00 at mylangara dot bc.ca
2014-07-19  1:10 ` sstewartgallus00 at mylangara dot bc.ca
2014-07-19 18:34 ` sstewartgallus00 at mylangara dot bc.ca
2014-07-19 18:55 ` bugdal at aerifal dot cx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).