// Copyright (c) 2025 shibedrill // SPDX-License-Identifier: GPL-3.0-or-later use crate::arch::paging::{PageDirectory, PageTable}; use crate::memory::alloc; use alloc::string::String; use alloc::vec::Vec; use spin::Mutex; #[allow(dead_code)] pub static PROCESS_TABLE: Mutex> = Mutex::new(Vec::new()); // Currently running process. Invalid once the referenced process dies and // is destructed. #[allow(dead_code)] pub static CURRENT_PROCESS: Mutex> = Mutex::new(None); #[allow(dead_code)] pub struct Process { /// Unique process ID. proc_id: u32, /// ID of the parent process. parent_proc_id: 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_pointer: usize, /// The page direcory pointing to this process's pages. page_directory: PageDirectory, /// All pages owned by the process. /// When creating a process, we should create one read-write data page, /// with execution disabled, and one read-only executable page. page_tables: Vec, /// Process priority. Lower number is higher priority. priority: u16, } #[allow(dead_code)] pub fn context_switch() -> ! { loop {} } #[allow(dead_code)] pub enum ProcessState { // The process is the one being currently executed. Running, // The process is blocked by a syscall. Waiting, // The process is voluntarily napping until an alarm goes off. Sleeping, // The process has been "paused", and can be resumed or killed. Suspended, }