pub unsafe extern "C" fn switch_to(
prev_ctx: *mut KernelContext,
next_ctx: *const KernelContext,
)Expand description
Switch from the current kernel context to the next kernel context
This function performs a complete kernel context switch:
- Saves callee-saved registers (sp, ra, s0-s11) to prev_ctx
- Restores callee-saved registers from next_ctx
- Returns to the point where next_ctx was previously switched out
§Arguments
prev_ctx- Mutable reference to store the current contextnext_ctx- Reference to the context to switch to
§Safety
This function must only be called from kernel code with valid contexts. The stack pointers in both contexts must point to valid, allocated stacks.
§Returns
This function returns twice:
- Once immediately (when switching away from this context)
- Once when this context is resumed later