From 14d63f496118f4243f28ddf3218523aa36a80322 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 3 Jul 2019 20:36:52 +0200 Subject: [PATCH] fix (cross-core) initialization barriers --- macros/src/codegen/post_init.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 3f1e445122..19773e45bd 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -25,8 +25,12 @@ pub fn codegen( if analysis.timer_queues.is_empty() { // cross-initialization barriers -- notify *other* cores that their resources have been // initialized - if analysis.initialization_barriers.contains_key(&core) { - let ib = util::init_barrier(core); + for (user, initializers) in &analysis.initialization_barriers { + if !initializers.contains(&core) { + continue; + } + + let ib = util::init_barrier(*user); let shared = if cfg!(feature = "heterogeneous") { Some(quote!( #[rtfm::export::shared] @@ -46,14 +50,12 @@ pub fn codegen( } // then wait until the other cores have initialized *our* resources - for (&initializer, users) in &analysis.initialization_barriers { - if users.contains(&core) { - let ib = util::init_barrier(initializer); + if analysis.initialization_barriers.contains_key(&core) { + let ib = util::init_barrier(core); - stmts.push(quote!( - #ib.wait(); - )); - } + stmts.push(quote!( + #ib.wait(); + )); } // cross-spawn barriers: wait until other cores are ready to receive messages