Thread

Struct Thread 

Source
#[repr(C)]
pub struct Thread { pub(crate) sp: usize, pub(crate) stack: Box<ThreadStack>, pub tid: u64, pub name: String, pub state: Arc<SpinLock<ThreadState>>, pub(crate) running_cpu: Arc<AtomicI32>, pub exit_status: Arc<AtomicU64>, pub interrupt_frame: SpinLock<*const Registers>, pub(crate) tty_hook: SpinLock<Option<Arc<SpinLock<TtyState>>>>, pub(crate) allocations: SpinLock<Option<BTreeMap<Kva, &'static Location<'static>>>>, /* private fields */ }
Expand description

An thread abstraction.

Fields§

§sp: usize

A stack pointer on context switch.

§WARNING

DO NOT CHANGE THE OFFSET THIS FIELDS. This offset used in context switch with hard-coded value. You must add your own members BELOWS this sp field.

§stack: Box<ThreadStack>

Thread Stack

§tid: u64

Thread id

§name: String

Thread name

§state: Arc<SpinLock<ThreadState>>

State of the thread.

§running_cpu: Arc<AtomicI32>§exit_status: Arc<AtomicU64>

Mixture of exit state (63th and 62th bit) and exit code (lower 32 bits).

§interrupt_frame: SpinLock<*const Registers>

Interrupt Frame if thread was handling interrupt.

§tty_hook: SpinLock<Option<Arc<SpinLock<TtyState>>>>§allocations: SpinLock<Option<BTreeMap<Kva, &'static Location<'static>>>>

Implementations§

Source§

impl Thread

Source

pub(crate) unsafe fn do_run(&mut self)

Source

pub(crate) fn run(self: Box<Self>)

Source

pub fn pin() -> ThreadPinGuard

Pin current thread not to be scheduled by blocking interrupt.

When ThreadPinGuard is dropped, the current thread is unpinned. When you hold multiple ThreadPinGuard, you MUST drops ThreadPinGuard as a reverse order of creation.

Auto Trait Implementations§

§

impl !Freeze for Thread

§

impl !RefUnwindSafe for Thread

§

impl !Send for Thread

§

impl !Sync for Thread

§

impl Unpin for Thread

§

impl !UnwindSafe for Thread

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
§

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.