Initialize contexts, add getpid

This commit is contained in:
Jeremy Soller
2016-08-20 14:32:45 -06:00
parent 47280a921a
commit aecfa50029
4 changed files with 37 additions and 8 deletions
+12 -1
View File
@@ -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)
}
}