#pragma once #include #include #include #ifdef __cplusplus #include #include typedef size_t pid_t; class process; struct thread; struct process_attr { uint16_t system : 1; }; struct thread_attr { uint32_t system : 1; uint32_t ready : 1; uint32_t wait : 1; }; struct thread { void* eip; process* owner; regs_32 regs; uint32_t eflags; thread_attr attr; }; class process { public: mm_list mms; types::list thds; // TODO: allocate a kernel stack for EVERY THREAD void* k_esp; process_attr attr; pid_t pid; public: process(process&& val); process(const process&) = delete; process(const process& proc, const thread& main_thread); // only used for system initialization process(void* start_eip); }; // in process.cpp extern process* current_process; extern thread* current_thread; extern "C" void NORETURN init_scheduler(); void do_scheduling(interrupt_stack* intrpt_data); void thread_context_save(interrupt_stack* int_stack, thread* thd); void thread_context_load(interrupt_stack* int_stack, thread* thd); void process_context_save(interrupt_stack*, process*); void process_context_load(interrupt_stack*, process* proc); void add_to_process_list(process&& proc); void add_to_ready_list(thread* thd); void k_new_thread(void (*func)(void*), void* data); #else void NORETURN init_scheduler(); #endif