Is a combination of atomic CAS for 64 and 32 bit ok?

Issue

This Content is from Stack Overflow. Question asked by Johan

My global array contains struct {float,float}. The first thing I do to it is a 64bit CAS on one of the structs. Depending on the return value I (may) want to modify the second float. Now I have the option of either using a 32bit CAS, or a 64bit. I know (based on the return value of the first CAS) that the first float will not change value again.

  • Is it safe to combine 64 bit CAS and 32 bit CAS on the same 64 bit memory?
  • Are there performance considerations to pick one or the other?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?