←back to thread

149 points whack | 1 comments | | HN request time: 0s | source
Show context
groundzeros2015 ◴[] No.45780994[source]
Did this article share more than one myth?

The reason why programmers don’t believe in cache coherency is because they have experienced a closely related phenomena, memory reordering. This requires you to use a memory fence when accessing a shared value between multiples cores - as if they needed to synchronize.

replies(2): >>45781211 #>>45781571 #
igtztorrero ◴[] No.45781571[source]
In Golang there are sync.Mutex, sync.Atomic and Channels to create this fence and prevent data races. I prefer sync.Mutex.

Does anyone understand how Go handles the CPU cache?

replies(1): >>45783554 #
groundzeros2015 ◴[] No.45783554[source]
Yes. Locks will use a memory fence. More advanced programs will need fence without locking.
replies(1): >>45784556 #
1. ◴[] No.45784556[source]