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:
commit
f807c951d6
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user