process.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <kernel/interrupt.h>
  3. #include <kernel/task.h>
  4. #include <types/types.h>
  5. #ifdef __cplusplus
  6. #include <kernel/mm.hpp>
  7. #include <types/list.hpp>
  8. class process;
  9. struct thread;
  10. struct process_attr {
  11. uint16_t system : 1;
  12. };
  13. struct thread_attr {
  14. uint32_t system : 1;
  15. uint32_t ready : 1;
  16. uint32_t wait : 1;
  17. };
  18. struct thread {
  19. void* eip;
  20. process* owner;
  21. regs_32 regs;
  22. uint32_t eflags;
  23. uint32_t esp;
  24. thread_attr attr;
  25. };
  26. class process {
  27. public:
  28. mm_list mms;
  29. types::list<thread> thds;
  30. void* k_esp;
  31. process_attr attr;
  32. public:
  33. process(process&& val);
  34. process(const process&) = delete;
  35. process(void* start_eip, uint8_t* image, size_t image_size, bool system);
  36. };
  37. // in process.cpp
  38. extern process* current_process;
  39. extern thread* current_thread;
  40. extern "C" void NORETURN init_scheduler();
  41. void do_scheduling(interrupt_stack* intrpt_data);
  42. void thread_context_save(interrupt_stack* int_stack, thread* thd, bool kernel);
  43. void thread_context_load(interrupt_stack* int_stack, thread* thd, bool kernel);
  44. void process_context_save(interrupt_stack*, process*);
  45. void process_context_load(interrupt_stack*, process* proc);
  46. #else
  47. void NORETURN init_scheduler();
  48. #endif