Commit 29452bb1 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

add barrier before entering the idle loop

- barrier is necessary to avoid a race
- after the barrier all data structures are initialized
parent d39dcc85
......@@ -58,6 +58,7 @@ extern crate x86;
use alloc::alloc::Layout;
use core::alloc::GlobalAlloc;
use core::sync::atomic::{spin_loop_hint, AtomicU32, Ordering};
use arch::percore::*;
use mm::allocator::LockedHeap;
......@@ -257,6 +258,16 @@ extern "C" fn initd(_arg: usize) {
}
}
fn synch_all_cores() {
static CORE_COUNTER: AtomicU32 = AtomicU32::new(0);
CORE_COUNTER.fetch_add(1, Ordering::SeqCst);
while CORE_COUNTER.load(Ordering::SeqCst) != get_processor_count() {
spin_loop_hint();
}
}
/// Entry Point of HermitCore for the Boot Processor
#[cfg(not(test))]
fn boot_processor_main() -> ! {
......@@ -282,6 +293,8 @@ fn boot_processor_main() -> ! {
arch::boot_application_processors();
}
synch_all_cores();
// Start the initd task.
scheduler::PerCoreScheduler::spawn(initd, 0, scheduler::task::NORMAL_PRIO, 0, USER_STACK_SIZE);
......@@ -300,6 +313,8 @@ fn application_processor_main() -> ! {
info!("Entering idle loop for application processor");
synch_all_cores();
let core_scheduler = core_scheduler();
// Run the scheduler loop.
loop {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment