← Back to team overview

maria-developers team mailing list archive

Re: Rev 2740: Group commit for maria storage engine. in file:///Users/bell/maria/bzr/work-maria-5.2-groupcommit/

 

Hi!

10 февр. 2010, в 21:38, Sergei Golubchik написал(а):
[skip]
Why use my_atomic_store32 ?

As I understood idea of atomic operation it is guaranted that we will
read consistent value (not one byte from one value and other one from
other). Yes I remember your statement that on modern 32bit system you
always get it consistent, then why we made atomic operations at all?

Because my_atomic_store32() also adds a full memory barrier to the
atomic store operation. That is, if you do

  my_atomic_store32(&a, 1);
  my_atomic_store32(&b, 2);

and then in another thread

  if (my_atomic_load32(&b) == 2)
  {
    ...
    here you can be sure that a==1, because a=1 was executed before
    b=2. And neither compiler nor the cpu swapped two assignments.
  }


In other words it is real current value of the variable in all threads. It looks like what I need.


Follow ups

References