Safe Lock-free Primitives with iceoryx2's ByteAtomic
4 hours ago
- Sequence locks detect concurrent modifications but still cause undefined behavior due to non-atomic memory copies.
- iceoryx2's ByteAtomic provides byte-wise atomic read/write to prevent undefined behavior during memory copies.
- ByteAtomic avoids copying uninitialized memory (like padding bytes) by using the AtomicCopy trait for field-wise copying.
- The read operation returns MaybeTorn<T> to indicate potential torn reads, requiring additional synchronization checks.
- A derive macro simplifies implementing AtomicCopy for structs, making the wrapper easy to use.
- ByteAtomic enables correct and safe implementation of sequence locks and other lock-free primitives in safety-critical systems.