Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
[#1289](https://github.com/eclipse-iceoryx/iceoryx2/issues/1289)
* Add source `NodeId` to request and response header
[#1308](https://github.com/eclipse-iceoryx/iceoryx2/issues/1308)
* Add source `NodeId` to request and response header
[#1308](https://github.com/eclipse-iceoryx/iceoryx2/issues/1308)
* Add support for platforms that do not support 64-bit atomics
[#1324](https://github.com/eclipse-iceoryx/iceoryx2/issues/1324)

### Bugfixes

Expand Down
18 changes: 16 additions & 2 deletions iceoryx2-pal/concurrency-sync/src/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,32 @@ pub type AtomicI32 = core::sync::atomic::AtomicI32;
pub type AtomicI32 = loom::sync::atomic::AtomicI32;

/// Behaves like [`core::sync::atomic::AtomicI64`]
#[cfg(not(all(test, loom, feature = "std")))]
#[cfg(all(not(all(test, loom, feature = "std")), target_has_atomic = "64"))]
#[allow(clippy::disallowed_types)]
pub type AtomicI64 = core::sync::atomic::AtomicI64;

#[cfg(all(not(all(test, loom, feature = "std")), not(target_has_atomic = "64")))]
#[deprecated(
since = "0.0.1",
note = "This platform does not support native atomic 64-bit operations! iceoryx2 uses a 64-bit atomic based on spinlocks that cannot guarantee lock-free operations. A crash in one process may cause a deadlock in another process."
)]
Comment on lines +111 to +115
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly advice not to do this. All modern (newer than 30 years) CPU architectures not meant for microcontroller support 8 byte CAS also on 32 bit. For uCs, using a spin-lock will lead to deadlocks in common use cases, even if nothing goes wrong. For example, queues are often used to pass data from interrupt service routines to the main loop. iceoryx2 would be ideal for this use case. But with the spin-lock, this can deadlock when a subscriber takes samples in the main loop while a publisher publishes data in the ISR. The warning also does not give any hint that this can happen, because there are no processes on uCs. For anything that can run a process, we already support 8 byte CAS on 32 bit. But even for those use cases, as a user I have no clue what this means. I'm only using publish-subscribe and there is no warning about that, so I'm fine, right?

pub type AtomicI64 = Atomic<i64>;

#[cfg(all(test, loom, feature = "std"))]
pub type AtomicI64 = loom::sync::atomic::AtomicI64;

/// Behaves like [`core::sync::atomic::AtomicU64`]
#[cfg(not(all(test, loom, feature = "std")))]
#[cfg(all(not(all(test, loom, feature = "std")), target_has_atomic = "64"))]
#[allow(clippy::disallowed_types)]
pub type AtomicU64 = core::sync::atomic::AtomicU64;

#[cfg(all(not(all(test, loom, feature = "std")), not(target_has_atomic = "64")))]
#[deprecated(
since = "0.0.1",
note = "This platform does not support native atomic 64-bit operations! iceoryx2 uses a 64-bit atomic based on spinlocks that cannot guarantee lock-free operations. A crash in one process may cause a deadlock in another process."
)]
pub type AtomicU64 = Atomic<u64>;

#[cfg(all(test, loom, feature = "std"))]
pub type AtomicU64 = loom::sync::atomic::AtomicU64;

Expand Down
Loading