From afa61601c4c92aa88b159c596ff02a18661c7426 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Fri, 30 Jun 2023 14:49:08 +0200 Subject: [PATCH] Add ContextStatus::HardBlocked. --- src/context/context.rs | 17 +++++++++++++++++ src/scheme/sys/context.rs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/context/context.rs b/src/context/context.rs index aed8a03a..bcd42f65 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -35,10 +35,27 @@ int_like!(ContextId, AtomicContextId, usize, AtomicUsize); #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Status { Runnable, + + // TODO: Rename to SoftBlocked and move status_reason to this variant. + + /// Not currently runnable, typically due to some blocking syscall, but it can be trivially + /// unblocked by e.g. signals. Blocked, + + /// Not currently runnable, and cannot be runnable until manually unblocked, depending on what + /// reason. + HardBlocked { reason: HardBlockedReason }, + Stopped(usize), Exited(usize), } +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum HardBlockedReason { + AwaitingMmap, + // TODO: PageFaultOom? + // TODO: NotYetStarted/ManuallyBlocked (when new contexts are created) + // TODO: ptrace_stop? +} #[derive(Copy, Clone, Debug)] pub struct WaitpidKey { diff --git a/src/scheme/sys/context.rs b/src/scheme/sys/context.rs index 2a5aaca7..632b2e0e 100644 --- a/src/scheme/sys/context.rs +++ b/src/scheme/sys/context.rs @@ -43,7 +43,7 @@ pub fn resource() -> Result<Vec<u8>> { context::Status::Runnable => { stat_string.push('R'); }, - context::Status::Blocked => if context.wake.is_some() { + context::Status::Blocked | context::Status::HardBlocked { .. } => if context.wake.is_some() { stat_string.push('S'); } else { stat_string.push('B'); -- GitLab