Struct Thread

Source
pub struct Thread {
    proc: Arc<Proc>,
    active_pins: AtomicU8,
    active_interrupts: AtomicU8,
    active_mutexes: PrivateCell<Cell<u16>>,
    sleeping: Gutex<usize>,
    profiling_ticks: PrivateCell<Cell<u32>>,
    active_heap_guard: PrivateCell<Cell<usize>>,
}
Expand description

Implementation of thread structure.

All thread must run to completion once execution has been started otherwise resource will be leak if the thread is dropped while its execution currently in the kernel space.

We subtitute TDP_NOSLEEPING with td_intr_nesting_level and td_critnest since it is the only cases the thread should not allow to sleep.

Do not try to access any RefCell fields from interrupt handler because it might currently locked.

Fields§

§proc: Arc<Proc>§active_pins: AtomicU8§active_interrupts: AtomicU8§active_mutexes: PrivateCell<Cell<u16>>§sleeping: Gutex<usize>§profiling_ticks: PrivateCell<Cell<u32>>§active_heap_guard: PrivateCell<Cell<usize>>

Implementations§

Source§

impl Thread

Source

pub fn new_bare(proc: Arc<Proc>) -> Self

This function does not do anything except initialize the struct memory. It is the caller responsibility to configure the thread after this so it have a proper states and trigger necessary events.

§Context safety

This function does not require a CPU context.

Source

pub fn can_sleep(&self) -> bool

Source

pub fn proc(&self) -> &Arc<Proc>

Source

pub unsafe fn active_pins(&self) -> &AtomicU8

See crate::context::pin_cpu() for a safe wrapper.

§Safety

Once this value is zero this thread can switch to a different CPU. The code after this value decrement must not depend on a specific CPU.

This value must not modified by the other thread.

Source

pub unsafe fn active_interrupts(&self) -> &AtomicU8

§Safety

This value can only modified by interrupt entry point.

Source

pub fn active_mutexes(&self) -> u16

§Panics

If called from the other thread.

Source

pub fn set_active_mutexes(&self, v: u16)

§Panics

If called from the other thread.

Source

pub fn sleeping_mut(&self) -> GutexWrite<'_, usize>

Sleeping address. Zero if this thread is not in a sleep queue.

Source

pub fn set_profiling_ticks(&self, v: u32)

§Panics

If called from the other thread.

Source

pub fn active_heap_guard(&self) -> usize

§Panics

If called from the other thread.

Source

pub fn disable_vm_heap(&self) -> HeapGuard<'_>

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.