mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-04-25 11:49:03 +02:00
Add a scheduler which just keeps of processes for now, and a
with_process to interact with them. User space now has it's own address space and mapper which means we will be able to allocate memory for it. I added a bunch of functions as stubs into libxunil which are required for doomgeneric.
This commit is contained in:
32
kernel/src/task/process.rs
Normal file
32
kernel/src/task/process.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use crate::{arch::x86_64::paging::XunilFrameAllocator, mm::address_space::AddressSpace};
|
||||
|
||||
enum ProcessState {
|
||||
Ready,
|
||||
Running,
|
||||
Blocked,
|
||||
Zombie,
|
||||
}
|
||||
|
||||
pub struct Process {
|
||||
pub pid: u64,
|
||||
pub state: ProcessState,
|
||||
// cpu_ctx: &[u8],
|
||||
pub address_space: AddressSpace,
|
||||
pub user_entry: u64,
|
||||
}
|
||||
impl Process {
|
||||
pub fn new(
|
||||
pid: u64,
|
||||
user_entry: u64,
|
||||
frame_allocator: &mut XunilFrameAllocator,
|
||||
) -> Option<Process> {
|
||||
let address_space = AddressSpace::new(frame_allocator)?;
|
||||
|
||||
Some(Process {
|
||||
pid,
|
||||
state: ProcessState::Ready,
|
||||
address_space,
|
||||
user_entry,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user