#[repr(C)]pub struct TaskContext {}Expand description
Saved hardware states of a task.
The context usually includes:
- Callee-saved registers
- Stack pointer register
- Thread pointer register (for kernel-space thread-local storage)
- FP/SIMD registers
On context switch, current task saves its context from CPU to memory, and the next task restores its context from memory to CPU.
Fields§
§sp: u64§r19: u64§r20: u64§r21: u64§r22: u64§r23: u64§r24: u64§r25: u64§r26: u64§r27: u64§r28: u64§r29: u64§lr: u64§tpidr_el0: u64Thread Pointer
Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub fn new() -> TaskContext
pub fn new() -> TaskContext
Sourcepub fn init(&mut self, entry: usize, kstack_top: VirtAddr, tls_area: VirtAddr)
pub fn init(&mut self, entry: usize, kstack_top: VirtAddr, tls_area: VirtAddr)
Initializes the context for a new task, with the given entry point and kernel stack.
Sourcepub fn switch_to(&mut self, next_ctx: &TaskContext)
pub fn switch_to(&mut self, next_ctx: &TaskContext)
Switches to another task.
It first saves the current task’s context from CPU to this place, and then
restores the next task’s context from next_ctx to CPU.
Trait Implementations§
Source§impl Debug for TaskContext
impl Debug for TaskContext
Source§impl Default for TaskContext
impl Default for TaskContext
Source§fn default() -> TaskContext
fn default() -> TaskContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TaskContext
impl RefUnwindSafe for TaskContext
impl Send for TaskContext
impl Sync for TaskContext
impl Unpin for TaskContext
impl UnsafeUnpin for TaskContext
impl UnwindSafe for TaskContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more