Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #145970

Example uses for read-modify-write operations?

From Philipp Klaus Krause <pkk@spth.de>
Newsgroups comp.lang.c
Subject Example uses for read-modify-write operations?
Date 2019-09-04 11:20 +0200
Organization solani.org
Message-ID <qknvks$rgm$2@solani.org> (permalink)

Show all headers | View raw


While I saw fetch-and-add mentioned a few times as useful, though not as
powerful as compare-and-swap, hardware and software tend to provide more
atomic read-modify-write operations.

Typically (e.g. in C), there are

fetch-and-add
fetch-and-subtract
fetch-and-bitwise-or
fetch-and-bitwise-xor
fetch-and-bitwise-and
fetch-and-increment
fetch-and-decrement

That return the previous value before modification. There also are the
operators that work as read-modify-write (++, --, +=, -=, <<=, >>=, *=,
/*, %=, &=, |=, ^=) on atomics that instead return the new value.

Could someone please point me to examples of algorithms that use these?

Philipp

P.S.: I already tried to post this 4 hours ago, but it didn't show up
yet. Sorry if this results in a double post.

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 11:20 +0200
  Re: Example uses for read-modify-write operations? Clifford Heath <no.spam@please.net> - 2019-09-04 20:44 +1000
    Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 13:26 +0200
      Re: Example uses for read-modify-write operations? Clifford Heath <no.spam@please.net> - 2019-09-04 22:13 +1000
        Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 14:33 +0200
      Re: Example uses for read-modify-write operations? already5chosen@yahoo.com - 2019-09-04 05:14 -0700
        Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 14:35 +0200
        Re: Example uses for read-modify-write operations? mark.bluemel@gmail.com - 2019-09-04 08:24 -0700
          Re: Example uses for read-modify-write operations? already5chosen@yahoo.com - 2019-09-04 08:37 -0700
          Re: Example uses for read-modify-write operations? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-04 17:10 +0100
  Re: Example uses for read-modify-write operations? Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-04 14:28 +0200

csiph-web