9#ifndef MAXOS_PROCESSES_PROCESS_H
10#define MAXOS_PROCESSES_PROCESS_H
23namespace MaxOS::processes {
53 uintptr_t m_stack_pointer;
54 uintptr_t m_tss_stack_pointer;
56 char m_sse_save_region[512] __attribute__((aligned(16)));
59 Thread(
void (* _entry_point)(
void*),
void* args,
int arg_amount,
Process* parent);
62 void sleep(
size_t milliseconds);
73 [[nodiscard]] uintptr_t
tss_pointer()
const {
return m_tss_stack_pointer; }
95 Process(
const string&
name,
void (* _entry_point)(
void*),
void* args,
int arg_amount,
bool is_kernel =
false);
104 [[nodiscard]] uint64_t
pid()
const;
Stores the left, top, width and height of a rectangle.
Enables a resource to be used by only one instance at a time through locking and unlocking.
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.
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.
Manages the open resources for a process.
The execution context of a sub-process thread.
thread_state_t thread_state
The current state of the thread.
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.
size_t wakeup_time
The time at which the thread should wake up (if sleeping)
~Thread()
Destructor for the Thread class.
void save_cpu_state()
Saves the CPU state into the thread's execution_state structure.
system::cpu_status_t execution_state
The CPU state of the thread.
uintptr_t tss_pointer() const
Gets the stack pointer to use for the TSS when switching to this thread.
void restore_sse_state()
Restores the SSE, x87 FPU, and MMX states from the thread to memory.
size_t ticks
The number of ticks the thread has run for.
void sleep(size_t milliseconds)
Sleeps the thread for a certain amount of time.
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 Map class for storing key-value pairs.
Defines classes for memory input and output operations of various bit widths (8, 16,...
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 String class for dynamically sized strings with various operations.
Defines a Vector class for dynamically storing an array of elements.
Defines a VirtualMemoryManager class for managing virtual memory allocation and mapping to physical m...