2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-19 00:16:29 +08:00

Rust: don't crash kernel CPU when no flash kernel is present.

This commit is contained in:
whitequark 2016-10-04 05:27:54 +00:00
parent 6bbaff81bf
commit 0cd87af386
2 changed files with 16 additions and 9 deletions

View File

@ -214,13 +214,6 @@ unsafe impl Send for WaitEvent {}
pub struct Waiter<'a>(&'a Yielder<WaitResult, WaitRequest, OwnedStack>);
impl<'a> Waiter<'a> {
pub fn relinquish(&self) {
self.0.suspend(WaitRequest {
timeout: None,
event: None
});
}
pub fn sleep(&self, duration: Duration) -> Result<()> {
let request = WaitRequest {
timeout: Some(Instant::now() + duration),
@ -242,6 +235,13 @@ impl<'a> Waiter<'a> {
}
}
pub fn relinquish(&self) -> Result<()> {
self.suspend(WaitRequest {
timeout: None,
event: None
})
}
pub fn join(&self, thread: ThreadHandle) -> Result<()> {
self.suspend(WaitRequest {
timeout: None,

View File

@ -320,7 +320,7 @@ fn host_kernel_worker(waiter: Waiter,
}
}
waiter.relinquish()
try!(waiter.relinquish())
}
}
@ -330,6 +330,13 @@ fn flash_kernel_worker(waiter: Waiter,
let mut session = Session::new(congress);
let kernel = config::read_to_end(config_key);
if kernel.len() == 0 {
info!("no kernel present in config key {}", config_key);
loop {
try!(waiter.relinquish())
}
}
try!(unsafe { kern_load(waiter, &mut session, &kernel) });
try!(kern_run(&mut session));
@ -410,6 +417,6 @@ pub fn handler(waiter: Waiter, spawner: Spawner) {
})
}
waiter.relinquish()
let _ = waiter.relinquish();
}
}