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


Groups > comp.lang.c > #145979

Re: Example uses for read-modify-write operations?

From Philipp Klaus Krause <pkk@spth.de>
Newsgroups comp.lang.c
Subject Re: Example uses for read-modify-write operations?
Date 2019-09-04 13:26 +0200
Organization solani.org
Message-ID <qko70n$r2$2@solani.org> (permalink)
References <qknvks$rgm$2@solani.org> <MAMbF.78233$gN2.1096@fx31.iad>

Show all headers | View raw


Am 04.09.19 um 12:44 schrieb Clifford Heath:
> On 4/9/19 7:20 pm, Philipp Klaus Krause wrote:
>> 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?
> 
> If the instructions are truly atomic (bus-locked, excluding intervention
> by DMA as well as other CPU cores and their caches) they can be used to
> implement the full spectrum of lock-free parallelisation primitives.
> 
> I know this because I've done it :)
> 

According to Herlihy, "Wait-Free Synchronization" (1991), the RMW
operations are stricly less powerful than compare-and-swap.
However, I am mostly interested in algorithms, where the RMW operations
come up naturally.

Philipp

Back to comp.lang.c | Previous | Next — Previous in thread | 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