4 ms·
No. * Data races using normal memory access function are impossible in safe code, and undefined behaviour in unsafe code. So unsafe code attempting this is inc
by CodesInChaos 6y ago
No.
* Data races using normal memory access function are impossible in safe code, and undefined behaviour in unsafe code. So unsafe code attempting this is incorrect.
* Data races using atomic types are possible in safe code. Some of the setup code might be unsafe internally while presenting a safe API (e.g. creating shared memory and giving you an `&[AtomicU8]` to that memory).
* Other race conditions (mostly non-deterministic order of lock acquisition) are also possible in safe code. The typical example of this is that writing to the console from multiple threads uses locks on individual write calls, which prevents torn writes but the order of those write outputs in non deterministic.