#![no_main] #![cfg_attr(target_os = "none", no_std)] const NLOOPS: i32 = 5; fn sleep_periodic(period: rt::tick::Utick) { rt::task::drop_privilege(); let mut last_wake_tick = 0; for _ in 0..NLOOPS { rt::task::sleep_periodic(&mut last_wake_tick, period); let now = rt::tick::count(); assert!((now - last_wake_tick) <= 1, "woke up at the wrong tick"); } // Only the second task to finish will call rt::trap. rt::sem!(TRAP_SEM, 1); if !TRAP_SEM.try_wait() { rt::trap(); } } const STACK_SIZE: usize = rt::stack::MIN * 8; rt::task!(sleep_periodic(5), STACK_SIZE, 0); rt::task!(sleep_periodic(10), STACK_SIZE, 1);