pub struct Thread {
pub id: usize,
pub registers: Registers,
kernel_stack: &'static mut [u32],
pub exited: bool,
action: extern "C" fn() -> !,
}
Expand description
The Thread is an object used by the scheduler.
Fields§
§id: usize
Thread id, each thread should have a different one
registers: Registers
Saved registers
kernel_stack: &'static mut [u32]
Kernel stack
exited: bool
If this thread has been killed
action: extern "C" fn() -> !
Function pointer
Implementations§
Source§impl Thread
impl Thread
pub fn init(&mut self, kernel_stack: &'static mut [u32])
Sourcepub fn kernel_stack(&self) -> *mut ()
pub fn kernel_stack(&self) -> *mut ()
Returns the top of the kernel stack pointer.
Sourceextern "C" fn kernel_kickoff(action: extern "C" fn())
extern "C" fn kernel_kickoff(action: extern "C" fn())
Kickoff function that is called in kernel mode.
If the thread was configured with a user stack, user_kickoff
is called in user mode.
Otherwise the action
is executed directly in the kernel.
Sourcepub fn resume(&mut self, next: &Self)
pub fn resume(&mut self, next: &Self)
Switches from the currently running thread to the next
one.
The values currently present in the callee-saved registers will be
stored in this threads context-structure, the corresponding values
belonging to next
thread will be loaded.
Sourcepub fn go(&self)
pub fn go(&self)
Activates the first thread on this CPU.
Calling the method starts the first thread on the calling CPU. From then on, Thread::resume must be used all subsequent context switches.