Implement sched_yield, enable interrupts in userspace
This commit is contained in:
parent
bd7bca30fa
commit
842826c1b0
5 changed files with 21 additions and 6 deletions
|
@ -30,6 +30,8 @@ pub enum Call {
|
|||
Exec = 11,
|
||||
/// Get process ID
|
||||
GetPid = 20,
|
||||
/// Yield to scheduler
|
||||
SchedYield = 158
|
||||
}
|
||||
|
||||
/// Convert numbers to calls
|
||||
|
@ -44,6 +46,7 @@ impl Call {
|
|||
6 => Ok(Call::Close),
|
||||
11 => Ok(Call::Exec),
|
||||
20 => Ok(Call::GetPid),
|
||||
158 => Ok(Call::SchedYield),
|
||||
_ => Err(Error::NoCall)
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +100,7 @@ pub fn handle(a: usize, b: usize, c: usize, d: usize, e: usize, _f: usize) -> Re
|
|||
Call::Close => close(b),
|
||||
Call::Exec => exec(convert_slice(b as *const u8, c)?, convert_slice(d as *const [usize; 2], e)?),
|
||||
Call::GetPid => getpid(),
|
||||
Call::SchedYield => sched_yield()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,3 +28,8 @@ pub fn getpid() -> Result<usize> {
|
|||
let context = context_lock.read();
|
||||
Ok(context.id)
|
||||
}
|
||||
|
||||
pub fn sched_yield() -> Result<usize> {
|
||||
unsafe { context::switch(); }
|
||||
Ok(0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue