sleep_ms() bug exhibitition

This commit is contained in:
bunnie 2021-03-18 17:34:48 +08:00
parent 6677d79834
commit 184a284da5
3 changed files with 35 additions and 10 deletions

View file

@ -12,7 +12,7 @@ pub fn callback_thread(_: u32) {
if CB_RUN.load(Ordering::Relaxed) { if CB_RUN.load(Ordering::Relaxed) {
CB_RUN.store(false, Ordering::Relaxed); CB_RUN.store(false, Ordering::Relaxed);
ticktimer_server::sleep_ms(ticktimer_conn, 2000).unwrap(); ticktimer_server::sleep_ms(ticktimer_conn, 10000).unwrap();
// just send a bogus message // just send a bogus message
xous::send_message(callback_conn, Message::Scalar(ScalarMessage{ xous::send_message(callback_conn, Message::Scalar(ScalarMessage{
id: 0xdeadbeef, arg1: 0, arg2: 0, arg3: 0, arg4: 0, id: 0xdeadbeef, arg1: 0, arg2: 0, arg3: 0, arg4: 0,
@ -38,7 +38,7 @@ impl CallBack {
} }
impl<'a> ShellCmdApi<'a> for CallBack { impl<'a> ShellCmdApi<'a> for CallBack {
cmd_api!(callback); cmd_api!(cb);
fn process(&mut self, _args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> { fn process(&mut self, _args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
use core::fmt::Write; use core::fmt::Write;

View file

@ -1,5 +1,10 @@
use xous::{Message, ScalarMessage}; use xous::{Message, ScalarMessage};
#[derive(Debug)]
pub struct TimerToken {
token: u64, // this field is 48 bits wide, random number
}
#[derive(Debug)] #[derive(Debug)]
pub enum Opcode { pub enum Opcode {
/// Reset the timer /// Reset the timer
@ -13,6 +18,24 @@ pub enum Opcode {
/// Recalculate the sleep time /// Recalculate the sleep time
RecalculateSleep, RecalculateSleep,
/*
////////// new APIs
/// Subscribe to wakeup alarms. Takes in the server name that's subcribed, returns a Token to refer to the subscription.
SubscribeWakeup(xous::String::<64>),
/// set an alarm in milliseconds, which is returned via the SubscribeWakeup registration token
WakeupAlarm(u16, TimerToken),
/// The generic message that gets sent to other servers, at the alarm time
WakeupMessage,
/// Request a blocking, in-line delay server -- returns a CID that can be used to send the BlockingDelayMs message
/// each request consumes a thread in the ticktimer that tracks & responds to a blockingdelay
RequestBlockingDelay,
/// Do a blocking delay. Responds with the current ElapsedMs by default.
BlockingDelayMs(u32),
*/
} }
impl<'a> core::convert::TryFrom<&'a Message> for Opcode { impl<'a> core::convert::TryFrom<&'a Message> for Opcode {

View file

@ -349,14 +349,16 @@ fn xmain() -> ! {
.expect("TickTimer: couldn't return time request"); .expect("TickTimer: couldn't return time request");
//info!("TickTimer: done returning value"); //info!("TickTimer: done returning value");
} }
Opcode::SleepMs(ms) => recalculate_sleep( Opcode::SleepMs(ms) => {
&mut ticktimer, recalculate_sleep(
&mut sleep_heap, &mut ticktimer,
Some(SleepResponse { &mut sleep_heap,
msec: ms, Some(SleepResponse {
sender: envelope.sender, msec: ms,
}), sender: envelope.sender,
), }),
);
}
Opcode::RecalculateSleep => { Opcode::RecalculateSleep => {
recalculate_sleep(&mut ticktimer, &mut sleep_heap, None); recalculate_sleep(&mut ticktimer, &mut sleep_heap, None);
//info!("TickTimer: Done recalculating"); //info!("TickTimer: Done recalculating");