Partial: migrate context handling code to RMM.
This commit is contained in:
+9
-3
@@ -1,12 +1,14 @@
|
||||
//! # Context management
|
||||
//!
|
||||
//! For resources on contexts, please consult [wikipedia](https://en.wikipedia.org/wiki/Context_switch) and [osdev](https://wiki.osdev.org/Context_Switching)
|
||||
use alloc::boxed::Box;
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::sync::atomic::Ordering;
|
||||
use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use spin::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
use crate::paging::{RmmA, RmmArch};
|
||||
use crate::syscall::error::{Error, ESRCH, Result};
|
||||
|
||||
pub use self::context::{Context, ContextId, ContextSnapshot, Status, WaitpidKey};
|
||||
pub use self::list::ContextList;
|
||||
@@ -89,3 +91,7 @@ pub fn context_id() -> ContextId {
|
||||
core::sync::atomic::compiler_fence(Ordering::Acquire);
|
||||
id
|
||||
}
|
||||
|
||||
pub fn current() -> Result<Arc<RwLock<Context>>> {
|
||||
contexts().current().ok_or(Error::new(ESRCH)).map(Arc::clone)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user