Let's say I've got a struct that consist of 100 bytes. What guarantees have I got about the following code?
m_myLargeStruct = someValue; // copying 100 bytes
Thread.MemoryBarrier();
// Executed by another thread, after "Thread.MemoryBarrier" was called by the first thread
Console.WriteLine(m_myLargeStruct.ToString());
Does the memory model guarantee that the 100 bytes copy will be complete after the placement of the memory barrier? or do memory barriers only apply for types that are at the size of the processor's architecture? (4 bytes for 32bit and 8 bytes to 64bit).
Is this the reason why the volatile keyword only applies for primitive types? (if i declare an 8 byte member as volatile, this means that an interlocked instrinct will be used to change it's value? [since atomicity isn't guaranteed for types larger than 4 bytes on 32bit machines]).
I hope I was clear enough.. :)
Thanks