Re: MemoryFence()

Paolo Bonzini <pbonzini@...>

On 05/02/21 14:15, Ni, Ray wrote:
I did some experiment.
// Copy EDKII MemoryFence() and as Laszlo said it's just a compiler fence.
void CompilerFence () {
This should be

#define CompilerFence _ReadWriteBarrier


void main () {
// I copied Paolo's code in below.
int *Address = &main;
int Value;
do {
// Force re-reading *Address on every iteration
CompilerFence ();
Value = *Address;
} while (Value == 0xFF);
// As you explained above.
__asm mfence;
----END of a.c----

Join to automatically receive all group messages.