#![no_main] #![cfg_attr(target_os = "none", no_std)] const N: i32 = 10; rt::sem!(SEM); fn poster() { rt::task::drop_privilege(); for _ in 0..N { rt::task::sleep(5); SEM.post(); } rt::task::sleep(15); SEM.post(); } fn waiter() { rt::task::drop_privilege(); for _ in 0..N { assert!(SEM.timed_wait(10), "wait timed out"); } assert!(!SEM.timed_wait(10), "wait didn't time out"); rt::trap(); } const STACK_SIZE: usize = rt::stack::MIN * 8; rt::task!(poster, rt::stack::MIN, 0); rt::task!(waiter, STACK_SIZE, 0);