1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

Merge pull request #50 from rcore-os/fix-nanosleep

This commit is contained in:
Chen 2020-05-11 16:02:23 +08:00 committed by GitHub
commit f807c951d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -300,8 +300,10 @@ impl Syscall<'_> {
pub fn sys_nanosleep(&mut self, req: *const TimeSpec) -> SysResult {
let time = unsafe { *self.vm().check_read_ptr(req)? };
info!("nanosleep: time: {:#?}", time);
// TODO: handle spurious wakeup
thread::sleep(time.to_duration());
if !time.is_zero() {
// TODO: handle spurious wakeup
thread::sleep(time.to_duration());
}
Ok(0)
}

View File

@ -149,6 +149,10 @@ impl TimeSpec {
nsec: (usec % USEC_PER_SEC * NSEC_PER_USEC) as usize,
}
}
pub fn is_zero(&self) -> bool {
self.sec == 0 && self.nsec == 0
}
}
// ignore other fields for now