#![no_main] #![cfg_attr(target_os = "none", no_std)] struct Point { x: u32, y: u32, } rt::rwlock!(POINT, Point, Point { x: 0, y: 0 }); fn reader() { rt::task::drop_privilege(); loop { let p = POINT.read(); assert_eq!(p.x, p.y, "point coordinates did not match"); } } fn writer() { rt::task::drop_privilege(); loop { let mut p = POINT.write(); p.x += 1; p.y += 1; drop(p); rt::task::sleep(1); } } fn timeout() { rt::task::drop_privilege(); rt::task::sleep(50); rt::trap(); } const STACK_SIZE: usize = rt::stack::MIN * 8; rt::task!(reader, STACK_SIZE, 1); rt::task!(reader, STACK_SIZE, 1); rt::task!(writer, rt::stack::MIN, 1); rt::task!(timeout, rt::stack::MIN, 0);