Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox2-51 shm long name support #53

Merged
13 changes: 1 addition & 12 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,4 @@ macos_aarch64_stable_debug_task:
- rustup component add clippy rustfmt
set_toolchain_script: rustup default stable
<<: *IOX2_CARGO_FMT_AND_CLIPPY
<<: *IOX2_COMMON_BUILD_DEBUG
test_script:
- cargo test -p iceoryx2-pal-concurrency-sync
-p iceoryx2-pal-posix
-p iceoryx2-bb-container
-p iceoryx2-bb-elementary
-p iceoryx2-bb-lock-free
-p iceoryx2-bb-log
-p iceoryx2-bb-memory
-p iceoryx2-bb-system-types
-p iceoryx2-bb-testing
--lib --bins --tests --no-fail-fast
<<: *IOX2_COMMON_BUILD_AND_TEST_DEBUG
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The support levels can be adjusted when required.
| Linux (x86_64) | done | tier 2 | tier 1 |
| Linux (aarch64) | done | tier 2 | tier 1 |
| Linux (32-bit) | in-progress | tier 3 | tier 1 |
| Mac OS | in-progress | tier 3 | tier 2 |
| Mac OS | done | tier 2 | tier 2 |
| QNX | planned | - | tier 1 |
| WatchOS | planned | - | tier 2 |
| Windows | done | tier 2 | tier 2 |
Expand Down
5 changes: 5 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* [ ] Zero-copy GPU communication with Cuda, NvSci, Vulkan
* [ ] Zero-copy across hypervisor partitions
* [ ] Zero-copy via QEMU ivshmem: <https://www.qemu.org/docs/master/system/devices/ivshmem.html>
* [ ] dmabuf support, see: https://blaztinn.gitlab.io/post/dmabuf-texture-sharing/
* [ ] Support dynamic sized types in a memory efficient manner
* Buddy allocator for sender data-segment
* Introduce runtime fixed-size types
Expand Down Expand Up @@ -128,3 +129,7 @@
* simple use case: pub/sub + event to notify subscriber to notify sample send
* would reduce error handling: connect to service with wrong messaging pattern
* [ ] Implement Resizable SharedMemoryConcept that is able to extend the shared memory by adding additional posix shared memory objects

## Integration Into Other Projects

* [ ] Maybe Hyprland
14 changes: 7 additions & 7 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# iceoryx2 v?.?.?

## [vx.x.x](https://github.com/larry-robotics/iceoryx2/tree/vx.x.x) (xxxx-xx-xx) <!--NOLINT remove this when tag is set-->
## [vx.x.x](https://github.com/eclipse-iceoryx/iceoryx2/tree/vx.x.x) (xxxx-xx-xx) <!--NOLINT remove this when tag is set-->
elBoberido marked this conversation as resolved.
Show resolved Hide resolved

[Full Changelog](https://github.com/larry-robotics/iceoryx2/compare/vx.x.x...vx.x.x) <!--NOLINT remove this when tag is set-->
[Full Changelog](https://github.com/eclipse-iceoryx/iceoryx2/compare/vx.x.x...vx.x.x) <!--NOLINT remove this when tag is set-->

### Features

* Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
* MacOS Platform support [#51](https://github.com/eclipse-iceoryx/iceoryx2/issues/51)

### Bugfixes

* Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
* Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### Refactoring

* Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
* Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### Workflow

* Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
* Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### New API features

* Example [#1](https://github.com/larry-robotics/iceoryx2/issues/1)
* Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### API Breaking Changes

Expand Down
28 changes: 14 additions & 14 deletions iceoryx2-bb/posix/src/condition_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<'mutex, 'handle, T: Debug> From<MutexLockError<'mutex, 'handle, T>>
/// use iceoryx2_bb_posix::mutex::*;
///
///
/// // create a condition variable which allows multiple predicates in wait_while nad
/// // create a condition variable which allows multiple predicates in blocking_wait_while nad
/// // timed_wait_while
/// let mtx_handle = MutexHandle::<i32>::new();
/// let condvar = ConditionVariableBuilder::new()
Expand Down Expand Up @@ -237,7 +237,7 @@ impl ConditionVariableBuilder {
/// modified and used for triggering.
///
/// The condition variable can use
/// multiple conditions in [`MultiConditionVariable::wait_while()`] and
/// multiple conditions in [`MultiConditionVariable::blocking_wait_while()`] and
/// [`MultiConditionVariable::timed_wait_while()`] but is only able to trigger all waiters.
pub fn create_multi_condition_variable<T: Debug>(
self,
Expand All @@ -252,7 +252,7 @@ impl ConditionVariableBuilder {
///
/// The condition variable has one fixed
/// condition which has to be provided on construction. The methods
/// [`ConditionVariable::wait_while()`] and
/// [`ConditionVariable::blocking_wait_while()`] and
/// [`ConditionVariable::timed_wait_while()`] will wait on that preset condition until
/// it is satisfied.
/// The restriction to a preset fixed condition comes with the feature to signal single waiters
Expand Down Expand Up @@ -489,7 +489,7 @@ pub trait BasicConditionVariableInterface<T: Debug>:
}

/// Condition variable which allows to use multiple conditions in
/// [`MultiConditionVariable::wait_while()`] and
/// [`MultiConditionVariable::blocking_wait_while()`] and
/// [`MultiConditionVariable::timed_wait_while()`] concurrently but with the draw
/// back that only all waiters can be triggered and not one.
/// The reason is when one waits on multiple
Expand All @@ -505,7 +505,7 @@ pub trait BasicConditionVariableInterface<T: Debug>:
/// is written.
/// The condition variable provides the following features:
/// * wait on the condition variable: [wait](BasicConditionVariableInterface::wait()), [timed_wait](BasicConditionVariableInterface::timed_wait())
/// * wait until a defined condition occurs: [wait_while](MultiConditionVariable::wait_while()), [timed_wait_while](MultiConditionVariable::timed_wait_while())
/// * wait until a defined condition occurs: [blocking_wait_while](MultiConditionVariable::blocking_wait_while()), [timed_wait_while](MultiConditionVariable::timed_wait_while())
/// * modify condition variable and then notify waiters:
/// [notify_all](MultiConditionVariable::notify_all()), [modify_notify_all](MultiConditionVariable::modify_notify_all())
/// * trigger waiters without changing condition variable: [trigger_all](BasicConditionVariableInterface::trigger_all())
Expand All @@ -530,7 +530,7 @@ pub trait BasicConditionVariableInterface<T: Debug>:
/// thread::scope(|s| {
/// let t1 = s.spawn(|| {
/// // wait until value is 5000
/// let guard = cv.wait_while(|t| *t == 5000).expect("failed to wait");
/// let guard = cv.blocking_wait_while(|t| *t == 5000).expect("failed to wait");
/// println!("cv value changed to 5000");
/// });
///
Expand Down Expand Up @@ -589,12 +589,11 @@ impl<'mtx_handle, T: Debug> MultiConditionVariable<'mtx_handle, T> {
/// [`MultiConditionVariable::modify_notify_all()`] or
/// [`BasicConditionVariableInterface::trigger_all()`]
/// and the provided predicate returns true.
pub fn wait_while<P: FnMut(&mut T) -> bool>(
pub fn blocking_wait_while<P: FnMut(&mut T) -> bool>(
&self,
mut predicate: P,
) -> Result<MutexGuard<'_, '_, T>, ConditionVariableWaitError<'_, '_, T>> {
let mut guard =
fail!(from self, when self.mutex.lock(), "Failed to lock mutex in wait_while.");
let mut guard = fail!(from self, when self.mutex.lock(), "Failed to lock mutex in blocking_wait_while.");

while !(predicate)(&mut *guard) {
self.condvar.pthread_wait(&self.mutex)?;
Expand Down Expand Up @@ -742,7 +741,7 @@ impl<T: Debug> Drop for ConditionVariableGuard<'_, '_, '_, T> {
}

/// Condition variable which requires a fixed predicate on creation which is then used in
/// [`ConditionVariable::wait_while()`] and
/// [`ConditionVariable::blocking_wait_while()`] and
/// [`ConditionVariable::timed_wait_while()`] concurrently with the benefit of triggering
/// single waiters.
/// The reason is when one waits on multiple
Expand All @@ -758,7 +757,7 @@ impl<T: Debug> Drop for ConditionVariableGuard<'_, '_, '_, T> {
/// is written.
/// The condition variable provides the following features:
/// * wait on the condition variable: [wait](BasicConditionVariableInterface::wait()), [timed_wait](BasicConditionVariableInterface::timed_wait())
/// * wait until a defined condition occurs: [wait_while](ConditionVariable::wait_while()), [timed_wait_while](ConditionVariable::timed_wait_while())
/// * wait until a defined condition occurs: [blocking_wait_while](ConditionVariable::blocking_wait_while()), [timed_wait_while](ConditionVariable::timed_wait_while())
/// * modify condition variable and then notify waiters:
/// [notify_all](ConditionVariable::notify_all()), [modify_notify_all](ConditionVariable::modify_notify_all()),
/// [notify_one](ConditionVariable::notify_one()), [modify_notify_one](ConditionVariable::modify_notify_one())
Expand Down Expand Up @@ -786,7 +785,7 @@ impl<T: Debug> Drop for ConditionVariableGuard<'_, '_, '_, T> {
/// thread::scope(|s| {
/// let t1 = s.spawn(|| {
/// // wait until value is 5000
/// let guard = cv.wait_while().expect("failed to wait");
/// let guard = cv.blocking_wait_while().expect("failed to wait");
/// println!("cv value is greater or equal 5000");
/// });
///
Expand Down Expand Up @@ -856,13 +855,14 @@ impl<'mtx_handle, T: Debug> ConditionVariable<'mtx_handle, T> {
/// [`BasicConditionVariableInterface::trigger_all()`] or
/// [`ConditionVariable::trigger_one()`]
/// and the provided predicate returns true.
pub fn wait_while(
pub fn blocking_wait_while(
&self,
) -> Result<
MutexGuard<'_, '_, ConditionVariableData<T>>,
ConditionVariableWaitError<'_, '_, ConditionVariableData<T>>,
> {
let guard = fail!(from self, when self.mutex.lock(), "failed to lock mutex in wait_while");
let guard =
fail!(from self, when self.mutex.lock(), "failed to lock mutex in blocking_wait_while");

while !self.call_underlying_predicate(&guard) {
self.condvar.pthread_wait(&self.mutex)?;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-bb/posix/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//!
//! ## Create a highly customized thread with guarded stack
//!
//! ```
//! ```ignore
//! use iceoryx2_bb_posix::thread::*;
//! use iceoryx2_bb_posix::scheduler::*;
//! use iceoryx2_bb_posix::system_configuration::*;
Expand Down
24 changes: 14 additions & 10 deletions iceoryx2-bb/posix/tests/condition_variable_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

use iceoryx2_bb_posix::condition_variable::*;
use iceoryx2_bb_testing::assert_that;
use iceoryx2_bb_testing::watchdog::Watchdog;
use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::time::Instant;

static TIMEOUT: Duration = Duration::from_millis(10);
static TIMEOUT: Duration = Duration::from_millis(100);

#[test]
fn multi_condition_variable_construction_works() {
Expand Down Expand Up @@ -48,7 +49,7 @@ fn multi_condition_variable_wait_while_is_signalled_by_notify_all() {

thread::scope(|s| {
let t1 = s.spawn(|| {
let guard = sut.wait_while(|t| *t == 4456).unwrap();
let guard = sut.blocking_wait_while(|t| *t == 4456).unwrap();
assert_that!(*guard, eq 4456);
});

Expand Down Expand Up @@ -77,7 +78,7 @@ fn multi_condition_variable_wait_while_is_signalled_by_modify_notify_all() {

thread::scope(|s| {
let t1 = s.spawn(|| {
let guard = sut.wait_while(|t| *t == 4456).unwrap();
let guard = sut.blocking_wait_while(|t| *t == 4456).unwrap();
assert_that!(*guard, eq 4456);
});

Expand Down Expand Up @@ -253,14 +254,14 @@ fn condition_variable_notify_all_signals_all_waiters() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
sut_thread1.wait_while().unwrap();
sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});

let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
sut_thread2.wait_while().unwrap();
sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});

Expand Down Expand Up @@ -299,14 +300,14 @@ fn condition_variable_notify_one_signals_one_waiter() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
sut_thread1.wait_while().unwrap();
sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});

let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
sut_thread2.wait_while().unwrap();
sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});

Expand Down Expand Up @@ -369,6 +370,7 @@ fn condition_variable_modify_notify_all_signals_all_waiters() {

#[test]
fn condition_variable_modify_notify_one_signals_one_waiter() {
let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::<ConditionVariableData<i32>>::new();
thread::scope(|s| {
let counter = Arc::new(AtomicI32::new(0));
Expand All @@ -381,21 +383,23 @@ fn condition_variable_modify_notify_one_signals_one_waiter() {
let sut_thread1 = Arc::clone(&sut);
let counter_thread1 = Arc::clone(&counter);
let t1 = s.spawn(move || {
sut_thread1.timed_wait_while(TIMEOUT * 10).unwrap();
sut_thread1.blocking_wait_while().unwrap();
counter_thread1.fetch_add(1, Ordering::Relaxed);
});

let sut_thread2 = Arc::clone(&sut);
let counter_thread2 = Arc::clone(&counter);
let t2 = s.spawn(move || {
sut_thread2.timed_wait_while(TIMEOUT * 10).unwrap();
sut_thread2.blocking_wait_while().unwrap();
counter_thread2.fetch_add(1, Ordering::Relaxed);
});

thread::sleep(TIMEOUT);
let counter_old_1 = counter.load(Ordering::Relaxed);
sut.modify_notify_one(|value| *value = 2213).unwrap();

while counter.load(Ordering::Relaxed) == 0 {}

thread::sleep(TIMEOUT);
let counter_old_2 = counter.load(Ordering::Relaxed);
sut.modify_notify_one(|value| *value = 2213).unwrap();
Expand Down Expand Up @@ -462,5 +466,5 @@ fn condition_variable_wait_while_does_not_wait_when_predicate_is_fulfilled() {
);
sut.lock().unwrap().value = 9999999;

assert_that!(sut.wait_while(), is_ok);
assert_that!(sut.blocking_wait_while(), is_ok);
}
5 changes: 4 additions & 1 deletion iceoryx2-bb/posix/tests/mutex_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ use iceoryx2_bb_posix::system_configuration::Feature;
use iceoryx2_bb_posix::unmovable_ipc_handle::AcquireIpcHandleError;
use iceoryx2_bb_testing::assert_that;
use iceoryx2_bb_testing::test_requires;
use iceoryx2_bb_testing::watchdog::Watchdog;
use std::sync::Arc;
use std::sync::Barrier;
use std::thread;
use std::time::Duration;

const TIMEOUT: Duration = Duration::from_millis(50);
const TIMEOUT: Duration = Duration::from_millis(100);

#[test]
fn mutex_lock_works() {
Expand Down Expand Up @@ -389,6 +390,7 @@ fn mutex_with_deadlock_detection_blocks() {

#[test]
fn mutex_can_be_recovered_when_thread_died() {
let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::<i32>::new();
let sut = MutexBuilder::new()
.thread_termination_behavior(MutexThreadTerminationBehavior::ReleaseWhenLocked)
Expand Down Expand Up @@ -429,6 +431,7 @@ fn mutex_can_be_recovered_when_thread_died() {

#[test]
fn mutex_in_unrecoverable_state_if_state_of_leaked_mutex_is_not_repaired() {
let _watchdog = Watchdog::new(Duration::from_secs(10));
let handle = MutexHandle::<i32>::new();
let sut = MutexBuilder::new()
.thread_termination_behavior(MutexThreadTerminationBehavior::ReleaseWhenLocked)
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-bb/posix/tests/shared_memory_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use iceoryx2_bb_testing::{assert_that, test_requires};
use iceoryx2_pal_posix::posix::POSIX_SUPPORT_PERSISTENT_SHARED_MEMORY;

fn generate_shm_name() -> FileName {
let mut file_name = FileName::new(b"shm_tests_").unwrap();
let mut file_name = FileName::new(b"shared_memory_tests_").unwrap();
file_name
.push_bytes(UniqueSystemId::new().unwrap().value().to_b64().as_bytes())
.unwrap();
Expand Down Expand Up @@ -92,7 +92,7 @@ fn shared_memory_create_and_modify_open_works() {
#[test]
fn shared_memory_opening_with_non_fitting_size_fails() {
let shm_name = generate_shm_name();
let _sut_create = SharedMemoryBuilder::new(&shm_name)
let sut_create = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::PurgeAndCreate)
.size(1024)
.permission(Permission::OWNER_ALL)
Expand All @@ -102,14 +102,14 @@ fn shared_memory_opening_with_non_fitting_size_fails() {

let sut_open1 = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::OpenOrCreate)
.size(8192)
.size(sut_create.size() + 1)
.permission(Permission::OWNER_ALL)
.zero_memory(true)
.create();

let sut_open2 = SharedMemoryBuilder::new(&shm_name)
.creation_mode(CreationMode::OpenOrCreate)
.size(16384)
.size(sut_create.size() * 2)
.permission(Permission::OWNER_ALL)
.zero_memory(true)
.create();
Expand Down
Loading