Partial: migrate context handling code to RMM.

This commit is contained in:
4lDO2
2022-07-17 14:13:46 +02:00
parent c912d9e0db
commit dc8ce1c22b
5 changed files with 131 additions and 104 deletions
+9 -3
View File
@@ -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)
}