public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: Ruslan Nikolaev <nruslan_devel@yahoo.com>
Cc: Simon Wright <simon@pushface.org>,
	Alexander Monakov <amonakov@ispras.ru>,
	 Florian Weimer <fweimer@redhat.com>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>,
	GCC Patches <gcc@gcc.gnu.org>
Subject: Re: GCC interpretation of C11 atomics (DR 459)
Date: Tue, 27 Feb 2018 19:32:00 -0000	[thread overview]
Message-ID: <1519754333.15077.782.camel@redhat.com> (raw)
In-Reply-To: <1707893425.5533821.1519752596079@mail.yahoo.com>

On Tue, 2018-02-27 at 17:29 +0000, Ruslan Nikolaev wrote:
> 
> 
> > Consider a producer-consumer relationship between two processes where
> > the producer doesn't want to wait for the consumer.  For example, the
> > producer could be an application that's being traced, and the consumer
> > is a trace aggregation tool.  The producer can provide a read-only
> > mapping to the consumer, and put a nonblocking ring buffer or something
> > similar in there.  That allows the consumer to read, but it still needs
> > atomic access because the consumer is modifying the ring buffer
> > concurrently.
> Sorry for getting into someone's else conversation... And what good solution gcc offers right now? It forces producer and consumer to use lock-based (BTW: global lock!)

It's not one global lock, but a lock from an array of locks (global per
process, though).

> approach for *both* producer and consumer if we are talking about 128-bit types.

But we're not talking about that special case of 128b types here.  The
majority of synchronization doesn't need more than machine word size.

> Therefore, sometimes producers *will* wait (by, effectively, blocking). Basically, it becomes useless.

No, such a program would have a bug anyway.  It wouldn't even
synchronize properly.  Please make yourself familiar with what the
standard means by "address-free".  This use case needs address-free, so
that's what the program has to ensure (and it can test that portably).
Only lock-free gives you address-free.

> In this case, I would rather use a lock-based approach which at least does not use a global lock.

The lock would need to be shared between processes in the example I
gave.  You have to build your own lock for that currently, because C/C++
don't give you any process-shared locks.

  reply	other threads:[~2018-02-27 17:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1615980330.4453149.1519617655582.ref@mail.yahoo.com>
2018-02-26  4:01 ` Ruslan Nikolaev via gcc
2018-02-26  5:50   ` Alexander Monakov
2018-02-26  7:24     ` Fw: " Ruslan Nikolaev via gcc
2018-02-26  8:20       ` Alexander Monakov
2018-02-26  8:43         ` Ruslan Nikolaev via gcc
2018-02-26 19:07       ` Torvald Riegel
2018-02-26 19:43         ` Ruslan Nikolaev via gcc
2018-02-26 22:49           ` Ruslan Nikolaev via gcc
2018-02-27  3:33             ` Ruslan Nikolaev via gcc
2018-02-27 10:34             ` Ramana Radhakrishnan
2018-02-27 11:14               ` Torvald Riegel
2018-02-27 12:39             ` Torvald Riegel
2018-02-27 13:04               ` Ruslan Nikolaev via gcc
2018-02-27 13:08                 ` Szabolcs Nagy
2018-02-27 13:17                   ` Ruslan Nikolaev via gcc
2018-02-27 16:40                     ` Torvald Riegel
2018-02-27 17:07                       ` Ruslan Nikolaev via gcc
2018-02-27 16:21                   ` Torvald Riegel
2018-02-27 16:16                 ` Torvald Riegel
2018-02-27 16:46                 ` Simon Wright
2018-02-27 16:52                   ` Florian Weimer
2018-02-27 17:30                   ` Torvald Riegel
2018-02-27 17:33                     ` Ruslan Nikolaev via gcc
2018-02-27 19:32                       ` Torvald Riegel [this message]
2018-02-27 17:59                     ` Simon Wright
2018-02-27 10:40           ` Fw: " Torvald Riegel
2018-02-26 18:56     ` Torvald Riegel
2018-02-26 12:30   ` Szabolcs Nagy
2018-02-26 13:57     ` Alexander Monakov
2018-02-26 14:51       ` Szabolcs Nagy
2018-02-26 14:53       ` Ruslan Nikolaev via gcc
2018-02-26 18:35         ` Torvald Riegel
2018-02-26 18:59           ` Ruslan Nikolaev via gcc
2018-02-26 19:20             ` Torvald Riegel
2018-02-26 18:16   ` Florian Weimer
2018-02-26 18:34     ` Ruslan Nikolaev via gcc
2018-02-26 18:36     ` Janne Blomqvist
2018-02-27 10:22       ` Florian Weimer
     [not found] <886227277.5611063.1519759959364.ref@mail.yahoo.com>
2018-02-27 20:20 ` Ruslan Nikolaev via gcc
2018-02-27 22:19   ` Torvald Riegel
2018-02-28  1:46     ` Ruslan Nikolaev via gcc

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=1519754333.15077.782.camel@redhat.com \
    --to=triegel@redhat.com \
    --cc=amonakov@ispras.ru \
    --cc=fweimer@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=nruslan_devel@yahoo.com \
    --cc=simon@pushface.org \
    --cc=szabolcs.nagy@arm.com \
    /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).