On Tue, Jan 13, 2015 at 12:22 PM, Niels Möller nisse@lysator.liu.se wrote:
Another question: We need some kind of memory barrier when writing and/or reading the initialized flag. The (unlikely) failure case is a thread reading the initialized flag, getting 1, and then reading one of the function pointers, and getting a too old value. What barrier-instruction(s) should be used, on x86_64 and ARM? It's probably easiest to add any needed sychronization functions to cpuid.asm, to avoid relying on compiler-specific features.
Is that really needed? I mean you are setting these values at the constructor, that is prior to any thread being created, and there shouldn't be multiple CPUs to worry about.
regards, Nikos