maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #02233
Re: Rev 2740: Group commit for maria storage engine. in file:///Users/bell/maria/bzr/work-maria-5.2-groupcommit/
Hi!
>>>>> "Sergei" == Sergei Golubchik <serg@xxxxxxxxxxxx> writes:
Sergei> Hi, Michael!
Sergei> On Feb 11, Michael Widenius wrote:
>>
>> Yes, but if you are only looking at one value, without regard of the
>> other, then you don't need to use my_atomic_load32()
Sergei> if 32-bit reads are always atomic - yes.
Sergei> I suppose we can assume that they are.
>> Another problem is that if the variables are related in any way,
>> atomic_load32 is not good enough as you can get 'a' and 'b' from
>> different instances in time.
>>
>> for example:
>>
>> a=b= 0;
>>
>> T1: my_atomic_store32(&a, 1);
>> T1: my_atomic_store32(&b, 2);
>>
>> T2: my_atomic_store32(&a, 3);
>> T2: my_atomic_store32(&b, 4);
>>
>> T3: a1= my_atomic_load32(&a);
>> T3: b1= my_atomic_load32(&b);
>>
>> this means that you can get the following values for a1 and b1:
>>
>> a1= 0 b1= 0
>> a1= 0 b1= 2
>> a1= 1 b1= 2
>> a1= 1 b1= 4
>> a1= 3 b1= 2
>> a1= 3 b1= 4
Sergei> and also
Sergei> a1=0 b1=4
Sergei> a1=1 b1=0
ok, I missed the above one.
Sergei> a1=3 b1=0
Ok, that is right. However, my intention was actually to have T2 to be
T1 (ie same process), in which case this option would be impossible.
Sergei> all the 9 variants are possible.
Sanja, when considering the above, are you sure your usage of
my_atomic_load/my_atmoic_store is correct?
For example:
+ my_atomic_rwlock_rdlock(&soft_sync_rwl);
+ min= my_atomic_load32(&soft_sync_min);
+ max= my_atomic_load32(&soft_sync_max);
+ sync_request= my_atomic_load32(&soft_need_sync);
+ my_atomic_store32(&soft_sync_min, max);
+ my_atomic_store32(&soft_need_sync, 0);
+ my_atomic_rwlock_rdunlock(&soft_sync_rwl);
In the above code, there is no gurantee that you read or write
related soft_sync_min and soft_sync_max values.
(See above table).
Also, as we concluded with Sergei, any code like:
+ my_atomic_rwlock_rdlock(&soft_sync_rwl);
+ min= my_atomic_load32(&soft_sync_min);
+ my_atomic_rwlock_rdunlock(&soft_sync_rwl);
There is no reason to have an my_atomic_rwlock instruction.
Regards,
Monty
References