#[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: usizeA 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: u64Thread id
name: StringThread 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
impl Thread
pub(crate) unsafe fn do_run(&mut self)
pub(crate) fn run(self: Box<Self>)
Sourcepub fn pin() -> ThreadPinGuard
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.