WIP: Separate process status from context status.

This commit is contained in:
4lDO2
2024-07-15 13:40:53 +02:00
parent 7fbe5c72e9
commit e67c040f69
7 changed files with 90 additions and 48 deletions
+8
View File
@@ -29,6 +29,7 @@ pub struct Process {
pub info: ProcessInfo,
/// Context is being waited on
pub waitpid: Arc<WaitMap<WaitpidKey, (ProcessId, usize)>>,
pub status: ProcessStatus,
/// Threads of process
pub threads: Vec<Weak<RwSpinlock<Context>>>,
}
@@ -69,6 +70,12 @@ impl DerefMut for Process {
&mut self.info
}
}
#[derive(Debug)]
pub enum ProcessStatus {
PossiblyRunnable,
Stopped(usize),
Exited(usize),
}
pub const INIT: ProcessId = ProcessId::new(1);
static NEXT_PID: AtomicProcessId = AtomicProcessId::new(INIT);
@@ -110,6 +117,7 @@ pub fn new_process(info: impl FnOnce(ProcessId) -> ProcessInfo) -> Result<Arc<Rw
let proc = Arc::try_new(RwLock::new(Process {
waitpid: Arc::try_new(WaitMap::new()).map_err(|_| Error::new(ENOMEM))?,
threads: Vec::new(),
status: ProcessStatus::PossiblyRunnable,
info: info(pid),
}))
.map_err(|_| Error::new(ENOMEM))?;