9#ifndef MAXOS_PROCESSES_PROCESS_H
10#define MAXOS_PROCESSES_PROCESS_H
12#include <libcommon/vector.h>
13#include <libcommon/string.h>
22namespace MaxOS::processes {
54 uintptr_t m_stack_pointer;
55 uintptr_t m_tss_stack_pointer;
57 uint8_t m_io_bitmap[system::IO_BITMAP_SIZE];
59 char m_sse_save_region[512] __attribute__((aligned(16)));
62 Thread(
void (* _entry_point)(
void*),
void* args,
int arg_amount,
Process* parent);
65 void sleep(
size_t milliseconds);
77 [[nodiscard]] uintptr_t
tss_pointer()
const {
return m_tss_stack_pointer; }
78 void set_tss_pointer(uintptr_t new_tss_pointer) { m_tss_stack_pointer = new_tss_pointer; }
97 common::Vector<Thread*> m_threads;
100 common::Spinlock m_lock;
104 Process(
const string&
name,
void (* _entry_point)(
void*),
void* args,
int arg_amount,
bool is_kernel =
false);
108 common::Vector<Thread*>
threads();
113 [[nodiscard]] uint64_t
pid()
const;
Handles memory allocation and deallocation.
Handles the loading and parsing of 64-bit ELF files.
A process that can be scheduled by the Scheduler, wraps & manages threads as well as its own address ...
uint64_t pid() const
Gets the pid of the process.
uint64_t total_ticks()
Gets the total ticks of the threads in the process (not this does not include any past killed threads...
string name
The name of the process.
resources::ResourceManager resource_manager
The manger for resources used by this process.
common::Vector< Thread * > threads()
Gets the threads of the process.
void add_thread(Thread *thread)
Adds a thread to the process.
~Process()
Destructor for the Process class.
string working_directory
The working directory of the process.
bool is_kernel
Whether this process is a kernel process.
void set_pid(uint64_t pid)
Sets the pid of the process once added to the queue.
void remove_thread(uint64_t tid)
Remove a thread by its tid (NOTE: this will not remove it from the scheduler)
memory::MemoryManager * memory_manager
The manager for memory used by this process.
The execution context of a sub-process thread.
void enable_port(uint64_t port)
Sets bits in the threads TSS to allow a port for I/O.
uint64_t parent_pid
The parent process ID.
void save_sse_state()
Saves the SSE, x87 FPU, and MMX states from memory to the thread.
uint64_t tid
The thread ID.
volatile system::cpu_status_t execution_state
The CPU state of the thread.
~Thread()
Destructor for the Thread class.
void yield()
Pass execution to the next ready thread.
volatile size_t ticks
The number of ticks the thread has run for.
void save_cpu_state()
Saves the CPU state into the thread's execution_state structure.
void set_tss_pointer(uintptr_t new_tss_pointer)
Sets the stack pointer to use for the TSS when switching to this thread.
void disable_port(uint64_t port)
Sets bits in the threads TSS to disallow a port for I/O.
uintptr_t tss_pointer() const
Gets the stack pointer to use for the TSS when switching to this thread.
volatile thread_state_t thread_state
The current state of the thread.
void restore_sse_state()
Restores the SSE, x87 FPU, and MMX states from the thread to memory.
volatile size_t wakeup_time
The time at which the thread should wake up (if sleeping)
void sleep(size_t milliseconds)
Sleeps the thread for a certain amount of time.
void load_port_bitmap()
Copy this ports.
Manages the open resources for a process.
Defines Central Processing Unit (CPU) structures and functions for managing CPU state and features.
struct PACKED MaxOS::system::CPUStatus cpu_status_t
Alias for CPUStatus struct.
Defines structures and enums for handling ELF (Executable and Linkable Format) files in MaxOS.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
Defines a MemoryManager class for handling memory allocation and deallocation.
constexpr size_t STACK_SIZE
The size of the stack for each thread (4KB)
ThreadState
The different operational states a thread can be in.
enum MaxOS::processes::ThreadState thread_state_t
Alias for ThreadState enum.
Defines classes for managing process resources such as files and devices.
Defines a VirtualMemoryManager class for managing virtual memory allocation and mapping to physical m...