Cpu

Struct Cpu 

Source
pub struct Cpu {
    pub current_task: Option<Arc<SpinLock<Task>>>,
    pub current_memory_space: Option<Arc<SpinLock<MemorySpace>>>,
}
Expand description

CPU 结构体

Fields§

§current_task: Option<Arc<SpinLock<Task>>>

任务上下文 用于在调度器中保存和恢复 CPU 寄存器状态 当前运行的任务

§current_memory_space: Option<Arc<SpinLock<MemorySpace>>>

当前使用的内存空间 对于内核线程,其本身相应字段为 None,因而使用上一个任务的内存空间

Implementations§

Source§

impl Cpu

Source

pub fn new() -> Self

创建一个新的 CPU 实例

Source

pub fn switch_task(&mut self, task: Arc<SpinLock<Task>>)

切换当前任务

§参数
  • task - 要切换到的任务
Source

pub fn switch_space(&mut self, space: Arc<SpinLock<MemorySpace>>)

切换当前内存空间

§参数
  • space - 要切换到的内存空间

Auto Trait Implementations§

§

impl Freeze for Cpu

§

impl !RefUnwindSafe for Cpu

§

impl Send for Cpu

§

impl Sync for Cpu

§

impl Unpin for Cpu

§

impl !UnwindSafe for Cpu

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.