public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [patch] Fix shared_timed_mutex::try_lock_until() et al
Date: Fri, 10 Apr 2015 09:56:00 -0000	[thread overview]
Message-ID: <1428659777.2909.1.camel@triegel.csb> (raw)
In-Reply-To: <20150410083757.GV9755@redhat.com>

On Fri, 2015-04-10 at 09:37 +0100, Jonathan Wakely wrote:
> On 10/04/15 02:16 +0200, Torvald Riegel wrote:
> >On Wed, 2015-04-08 at 20:38 +0100, Jonathan Wakely wrote:
> >> On 08/04/15 20:11 +0100, Jonathan Wakely wrote:
> >> >We can get rid of the _Mutex type then, and just use std::mutex,
> >> >and that also means we can provide the timed locking functions
> >> >even when !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK).
> >> >
> >> >And so maybe we should use this fallback implementation instead of
> >> the
> >> >pthread_rwlock_t one when !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK),
> >> >so that they have a complete std::shared_timed_mutex (this applies
> >> >to at least Darwin, not sure which other targets).
> >>
> >> Here's a further patch to do that (which really needs to go into
> >> 5.0 too, so we don't switch Darwin to the new pthread_rwlock_t
> >> version and then have to swtich it back again in 6.0).
> >
> >I understand why a mutex with timeouts isn't required anymore, but
> >why do you now add it to the USE_PTHREAD_RWLOCK_T condition?  If
> >pthread_rwlock_t is available, why would we need a normal mutex with
> >timeouts?
> 
> Darwin and HPUX support pthread_rwlock_t but not the timed lock
> functions, see https://gcc.gnu.org/PR64847 and (part of)
> https://gcc.gnu.org/PR64368 which were "fixed" by
> https://gcc.gnu.org/r220161 which just disables the timed lock
> functions on those targets, using #if _GTHREAD_USE_MUTEX_TIMEDLOCK.
> 
> That means Darwin and HPUX have an incomplete shared_timed_mutex that
> doesn't support the timed functions (i.e. what might get added to
> C++17 as std::shared_mutex).
> 
> The patch below gives Darwin and HPUX a fully conforming (albeit
> slower) shared_timed_mutex, by ensuring we don't use pthread_rwlock_t
> for targets that can't use timed functions with pthread_rwlock_t.
> 
> If std::shared_mutex is added to the standard we could use
> pthread_rwlock_t for that even on Darwin and HPUX, because it provides
> everything needed for a non-timed std::shared_mutex.

Ah, right.  I was confused by the name, thinking those targets don't
support pthread_mutex_timedlock, not pthread_rwlock_timedrdlock etc.

  reply	other threads:[~2015-04-10  9:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 14:28 Jonathan Wakely
2015-04-08 16:59 ` Torvald Riegel
2015-04-08 19:12   ` Jonathan Wakely
2015-04-08 19:38     ` Jonathan Wakely
2015-04-10  0:16       ` Torvald Riegel
2015-04-10  8:38         ` Jonathan Wakely
2015-04-10  9:56           ` Torvald Riegel [this message]
2015-04-10 10:21             ` Jonathan Wakely
2015-04-10  0:11     ` Torvald Riegel
2015-04-11 11:48     ` Jonathan Wakely

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=1428659777.2909.1.camel@triegel.csb \
    --to=triegel@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).