oligny

Multiprocessor cache-line scope coherency

Discussion created by oligny on Jul 17, 2008
Latest reply on Aug 20, 2008 by yeyang
Can spill-over corruption occurs if two processor write to nearby memory without mutex protection

I learned last month that when the CPU reads from memory, it reads a whole cache-line of 64 bytes (could be different depending on architecture).

Does it do the same when writing ?

If so, do I have to take care not to write nearby variables without mutex protection. Example:

typedef struct object_S
{
 int memberA; // writable only by thread A (running on CPU 0)
 int memberB; // writable only by thread C (running on CPU 1)
 int memberC;
 int memberD;
} object_T;


ThreadA:

object->memberA = 10;

ThreadB:

object->memberB = 60;

On a multiple processor system, can one CPU (running thread A) update memberA to 10, then the other CPU (running thread B) update memberB to 60 without worrying to overwrite memberA with an old/oudated value. I would be doing this without mutex protection.

Outcomes