Skip to content

Commit 56f1d31

Browse files
committed
samples: philosophers: Change sys::Mutex to dynamic
Switch to using dynamic Mutex types for this demo. Signed-off-by: David Brown <[email protected]>
1 parent 8cdf4a6 commit 56f1d31

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

samples/philosophers/src/sysmutex.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::{
1010
ForkSync,
1111
NUM_PHIL,
1212
};
13-
use zephyr::kobj_define;
1413
use zephyr::sys::sync::Mutex;
1514
use zephyr::time::Forever;
1615

@@ -27,8 +26,8 @@ pub struct SysMutexSync {
2726
impl SysMutexSync {
2827
#[allow(dead_code)]
2928
pub fn new() -> SysMutexSync {
30-
let locks = MUTEXES.each_ref().map(|m| {
31-
m.init_once(()).unwrap()
29+
let locks = [(); NUM_PHIL].each_ref().map(|()| {
30+
Mutex::new().unwrap()
3231
});
3332
SysMutexSync { locks }
3433
}
@@ -43,7 +42,3 @@ impl ForkSync for SysMutexSync {
4342
self.locks[index].unlock().unwrap();
4443
}
4544
}
46-
47-
kobj_define! {
48-
static MUTEXES: [StaticMutex; NUM_PHIL];
49-
}

0 commit comments

Comments
 (0)