53 lines
1.3 KiB
Rust
53 lines
1.3 KiB
Rust
#![allow(unused_imports)]
|
|
|
|
use crate::memory::MemoryRegion;
|
|
|
|
use crate::memory::alloc;
|
|
use alloc::string::String;
|
|
use alloc::vec::Vec;
|
|
|
|
#[allow(dead_code)]
|
|
pub struct ProcessTable {}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct Process {
|
|
/// Unique process ID.
|
|
proc_id: u32,
|
|
/// ID of the parent process.
|
|
parent_proc_id: u32,
|
|
/// List of all child processes.
|
|
child_proc_ids: Vec<u32>,
|
|
/// Human readable name of the process, should be the command.
|
|
name: String,
|
|
/// The base address of the process stack within its memory region.
|
|
stack_base_addr: usize,
|
|
/// The length of the stack. This, plus the start address, is the stack size.
|
|
stack_length: usize,
|
|
/// The stack pointer, which is relative to the memory region start.
|
|
stack_ptr: usize,
|
|
/// The region of memory allocated to the process.
|
|
mem_region: MemoryRegion,
|
|
/// Process priority. Lower number is higher priority.
|
|
prio: u16,
|
|
/// Which semaphor the process is waiting on.
|
|
semaphor_wait: Option<u32>,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub unsafe fn context_switch() -> ! {
|
|
#[allow(unused_unsafe)]
|
|
unsafe {
|
|
loop {
|
|
crate::arch::current::asm::halt();
|
|
}
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub enum ProcessState {
|
|
Running,
|
|
Waiting,
|
|
Sleeping,
|
|
Suspended,
|
|
}
|