I meant that without using atomics but when using aligned memory this could happen (and it is no harm):
- CPU core #1 looks into a memory location and finds zero (no hash)
- CPU core #1 recalculates hash and writes it to the memory location
- CPU core #2 looks into a memory location and finds zero (the cache is not yet synced)
- CPU core #2 recalculates hash and writes it to the memory location (same as the first one)
and this could not happen:
3. CPU core #2 looks into a memory location and finds a mixture of old and value partially written
Do you mean this could happen? Or do you mean that there is no guarantee that compiler will generate a code that accesses the value in one go and might choose to access it, say, byte by byte?