←back to thread

261 points tosh | 1 comments | | HN request time: 0.741s | source
Show context
cperciva ◴[] No.42069585[source]
We use atomic operations to update the pointers in a thread-safe manner

Are you sure about that? Atomics are not locks, and not all systems have strong memory ordering.

replies(3): >>42070126 #>>42070474 #>>42070917 #
CodesInChaos ◴[] No.42070917[source]
> not all systems have strong memory ordering

Atomics require you to explicitly specify a memory ordering for every operation, so the system's memory ordering doesn't really matter. It's still possible to get it wrong, but a lot easier than in (traditional) C.

replies(1): >>42071585 #
1. reitzensteinm ◴[] No.42071585[source]
It's still possible to incorrectly use relaxed operations, and have your algorithm only incidentally work because the compiler hasn't reordered them and you're on a CPU with a stronger memory model.

But yes, it's an order of magnitude easier to get portability right using the C++/Rust memory model than what came before.