pub struct Thread<K: Kernel> {Show 14 fields
pub process_link: Link,
pub active_link: Link,
process: Option<ProcessHandle<K>>,
pub(super) state: State,
pub(super) stack: Stack,
pub arch_thread_state: UnsafeCell<K::ThreadState>,
pub(super) owner: ThreadOwner<K>,
pub(super) ref_count: K::AtomicUsize,
pub(super) terminating: bool,
pub(super) join_event: Option<EventSignaler<K>>,
pub(super) exit_status: Option<ExitStatus>,
pub name: &'static str,
pub algorithm_state: SchedulerAlgorithmThreadState,
pub object: Option<ForeignRc<K::AtomicUsize, ThreadObject<K>>>,
}Fields§
§process_link: Link§active_link: Link§process: Option<ProcessHandle<K>>§state: State§stack: Stack§arch_thread_state: UnsafeCell<K::ThreadState>§owner: ThreadOwner<K>§ref_count: K::AtomicUsize§terminating: bool§join_event: Option<EventSignaler<K>>§exit_status: Option<ExitStatus>§name: &'static str§algorithm_state: SchedulerAlgorithmThreadStateThe state for the scheduler algorithm.
object: Option<ForeignRc<K::AtomicUsize, ThreadObject<K>>>Implementations§
Source§impl<K: Kernel> Thread<K>
impl<K: Kernel> Thread<K>
pub(super) fn take_process(&mut self) -> ProcessHandle<K>
pub fn get_exit_status(&self) -> Option<ExitStatus>
pub fn is_terminating(&self) -> bool
pub fn set_stack(&mut self, stack: Stack)
Sourcepub fn set_affinity(&mut self, _affinity: AffinityMask)
pub fn set_affinity(&mut self, _affinity: AffinityMask)
Sets the CPU affinity mask for this thread.
pub const fn new(name: &'static str, priority: Priority, stack: Stack) -> Self
pub fn get_object( &self, kernel: K, handle: u32, ) -> Option<ForeignRc<K::AtomicUsize, dyn KernelObject<K>>>
pub(super) extern "C" fn trampoline<A1: ThreadArg>( entry_point: usize, arg0: usize, arg1: usize, )
pub fn re_initialize_kernel_thread<A: ThreadArg>( &mut self, kernel: K, entry_point: fn(K, A), arg: A, )
pub fn initialize_kernel_thread<A: ThreadArg>( &mut self, kernel: K, entry_point: fn(K, A), arg: A, )
pub(super) fn set_process(&mut self, process: ProcessHandle<K>)
Sourcepub unsafe fn initialize_non_priv_thread(
&mut self,
kernel: K,
process: ProcessHandle<K>,
initial_pc: usize,
initial_sp: usize,
args: (usize, usize, usize),
) -> Result<()>
pub unsafe fn initialize_non_priv_thread( &mut self, kernel: K, process: ProcessHandle<K>, initial_pc: usize, initial_sp: usize, args: (usize, usize, usize), ) -> Result<()>
§Safety
It is up to the caller to ensure that *process is valid. Initialize the mutable parts of the non privileged thread, must be called once per thread prior to starting it
pub fn dump(&self)
Sourcepub fn process(&self) -> ProcessHandle<K>
pub fn process(&self) -> ProcessHandle<K>
Returns a reference to the thread’s parent process.
Sourcepub(super) fn get_ref(&self, kernel: K) -> ThreadHandle<K>
pub(super) fn get_ref(&self, kernel: K) -> ThreadHandle<K>
Return a reference counted ThreadHandle for this thread.
Sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
A simple ID for debugging purposes
Currently this is a pointer to the architecture specific thread state allowing it to match debugging output from the architecture implementation.
§Safety
The returned value should not be relied upon as being a valid pointer.
Even in the current implementation, id does not expose the pointer’s
provenance.
Sourcepub const unsafe fn const_id_from_thread_address(addr: *const ()) -> *const ()
pub const unsafe fn const_id_from_thread_address(addr: *const ()) -> *const ()
Computes the ID of a thread from its address.
§Safety
This exists to allow thread annotations to be generated at compile time for static threads that are initialized at runtime. This should not be called in any other circumstance.