I understand why memory barriers are needed, but I don’t get it in the case of Uniprocessor.
Do I have to deal with barriers even when I use UP? Every document explains them with SMP but not UP.
In the following code, is there any possibility that r2 == 0 in point a?
// the location 0xdeadbeef has a zero initial value
ldr r0, =0xdeadbeef
ldr r1, =0xdeadbeef
ldr r2, =1
str r2, [r0]
ldr r2, [r1]
// point a
There are memory barriers and compiler barriers.
Memory barriers are not required on a single processor (I’m not sure if hyperthreading counts as multiple processors) but compiler barriers are – the compiler could re-order the code in different threads such that you fail.