Lets say we have 2 processes, and a shared memory in between. Assume we also have a pointer to the start of shared memory in both processes. Setup: process 1 is writing to some offset from the start of the memory, and process 2 is continuously looping to copy the data from that offset. Also assume that there are no locks or atomics to enforce memory synchronization.
Process 1 :
char *sh_mem;
size_t offset;
char data[4];
memcpy(sh_mem + offset, data, 4);
Process 2:
char *sh_mem;
size_t offset;
char read[4];
while (true)
memcpy(read, sh_mem + offset, 4);
Assume same offset is given. So my doubt is, that after what delay, can we kind of guarantee that the process 2 is reading the value updated by process 1?
Also, it there some sort of mechanism which enforces that eventually process 2 will see the cache block its reading is dirty, and it should get the updated block. Makes sense to think that