Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. Thread

Thread

Struct Thread 

Source
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: SchedulerAlgorithmThreadState

The state for the scheduler algorithm.

§object: Option<ForeignRc<K::AtomicUsize, ThreadObject<K>>>

Implementations§

Source§

impl<K: Kernel> Thread<K>

Source

pub(super) fn take_process(&mut self) -> ProcessHandle<K>

Source

pub fn get_exit_status(&self) -> Option<ExitStatus>

Source

pub fn is_terminating(&self) -> bool

Source

pub fn set_stack(&mut self, stack: Stack)

Source

pub fn set_affinity(&mut self, _affinity: AffinityMask)

Sets the CPU affinity mask for this thread.

Source

pub const fn new(name: &'static str, priority: Priority, stack: Stack) -> Self

Source

pub fn get_object( &self, kernel: K, handle: u32, ) -> Option<ForeignRc<K::AtomicUsize, dyn KernelObject<K>>>

Source

pub(super) extern "C" fn trampoline<A1: ThreadArg>( entry_point: usize, arg0: usize, arg1: usize, )

Source

pub fn re_initialize_kernel_thread<A: ThreadArg>( &mut self, kernel: K, entry_point: fn(K, A), arg: A, )

Source

pub fn initialize_kernel_thread<A: ThreadArg>( &mut self, kernel: K, entry_point: fn(K, A), arg: A, )

Source

pub(super) fn set_process(&mut self, process: ProcessHandle<K>)

Source

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

Source

pub fn dump(&self)

Source

pub fn process(&self) -> ProcessHandle<K>

Returns a reference to the thread’s parent process.

Source

pub(super) fn get_ref(&self, kernel: K) -> ThreadHandle<K>

Return a reference counted ThreadHandle for this thread.

Source

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.

Source

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.

Source

pub const fn null_id() -> usize

Trait Implementations§

Source§

impl<K: Kernel> Adapter<Thread<K>> for ProcessThreadListAdapter<K>

Source§

impl<K: Kernel> Adapter<Thread<K>> for ThreadListAdapter<K>

Source§

impl<K: Kernel> Send for Thread<K>

Source§

impl<K: Kernel> Sync for Thread<K>

Auto Trait Implementations§

§

impl<K> !Freeze for Thread<K>

§

impl<K> !RefUnwindSafe for Thread<K>

§

impl<K> !Unpin for Thread<K>

§

impl<K> !UnsafeUnpin for Thread<K>

§

impl<K> !UnwindSafe for Thread<K>

§

impl<K> Forget for Thread<K>

§

impl<K> Move for Thread<K>

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
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

fn cast_into(self) -> U

§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.