ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Ruby developers <ruby-core@ruby-lang.org>
Subject: [ruby-core:68180] Re: [Ruby trunk - Bug #10867] [Feedback] An ATOMIC_GET operation should be written and used.
Date: Thu, 19 Feb 2015 04:38:30 +0000	[thread overview]
Message-ID: <20150219043829.GA3674@dcvr.yhbt.net> (raw)
In-Reply-To: <redmine.journal-51551.20150219031408.3caf1b60c274f831@ruby-lang.org>

nobu@ruby-lang.org wrote:
> Won't atomic operations using gcc's `__atomic`/`__sync` built-ins or other
> platform-provided functions make such barriers?

Yes, but we don't use these builtins for reading (rb_signal_buff_size, for
example)

For a CPU memory barrier, I've used a no-op "+ 0" to read a counter:

	__sync_add_and_fetch(&counter, 0)

If only a compiler barrier is necessary, I prefer to avoid volatile types
and use something like an ACCESS_ONCE macro (similar to our RB_GC_GUARD)
to cast to volatile as-needed.

I really wish Ruby were GPL so it can rely on URCU for nice things :/

  reply	other threads:[~2015-02-19  4:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-10867.20150218180006@ruby-lang.org>
2015-02-18 18:00 ` [ruby-core:68173] [Ruby trunk - Bug #10867] [Open] An ATOMIC_GET operation should be written and used sstewartgallus00
2015-02-19  3:14 ` [ruby-core:68177] [Ruby trunk - Bug #10867] [Feedback] " nobu
2015-02-19  4:38   ` Eric Wong [this message]
2015-02-19  4:35 ` [ruby-core:68178] [Ruby trunk - Bug #10867] " nobu
2015-02-19 22:19 ` [ruby-core:68193] " kosaki.motohiro

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-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150219043829.GA3674@dcvr.yhbt.net \
    --to=ruby-core@ruby-lang.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).