Initialize contexts, add getpid
This commit is contained in:
parent
3b8f396229
commit
5b9c821ff5
1 changed files with 37 additions and 8 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
use arch::interrupt::halt;
|
||||
|
||||
use super::{convert_slice, Result};
|
||||
use context;
|
||||
|
||||
use super::{convert_slice, Error, Result};
|
||||
|
||||
pub fn exit(status: usize) -> ! {
|
||||
println!("Exit {}", status);
|
||||
|
|
@ -19,3 +21,12 @@ pub fn exec(path: &[u8], args: &[[usize; 2]]) -> Result<usize> {
|
|||
println!("");
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
pub fn getpid() -> Result<usize> {
|
||||
if let Some(context_lock) = context::contexts().current() {
|
||||
let context = context_lock.read();
|
||||
Ok(context.id)
|
||||
} else {
|
||||
Err(Error::NoProcess)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue