feat: implement context switching, SavedContext with pc/status fields, wire all syscall outcomes and timer preemption
This commit is contained in:
@@ -113,6 +113,29 @@ impl<P: Platform> Kernel<P> {
|
||||
self.processes.get(pid).is_ok()
|
||||
}
|
||||
|
||||
pub fn thread_context(&self, tid: ThreadId) -> Option<&domain::thread::SavedContext> {
|
||||
self.threads.get(tid).ok().map(|t| t.saved_context())
|
||||
}
|
||||
|
||||
pub fn thread_context_mut(&mut self, tid: ThreadId) -> Option<&mut domain::thread::SavedContext> {
|
||||
self.threads.get_mut(tid).ok().map(|t| t.saved_context_mut())
|
||||
}
|
||||
|
||||
pub fn thread_process(&self, tid: ThreadId) -> Option<ProcessId> {
|
||||
self.threads.get(tid).ok().map(|t| t.process())
|
||||
}
|
||||
|
||||
pub fn current_thread(&self) -> Option<ThreadId> {
|
||||
let core = self.platform.core_id();
|
||||
self.scheduler.current(core)
|
||||
}
|
||||
|
||||
pub fn pick_next_thread(&mut self) -> Option<ThreadId> {
|
||||
use domain::scheduler::Scheduler;
|
||||
let core = self.platform.core_id();
|
||||
self.scheduler.next(core)
|
||||
}
|
||||
|
||||
pub fn create_endpoint(&mut self) -> Result<types::id::EndpointId, KernelError> {
|
||||
self.endpoints.create().ok_or(KernelError::NoFreeSlot)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user