General Purpose library for Freestanding C++ and POSIX systems
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

42 行
927 B

  1. #pragma once
  2. #include "gp_config.hpp"
  3. #include "gp/function.hpp"
  4. #include "gp/indexed_array.hpp"
  5. #include "gp/pointers.hpp"
  6. #include "gp/vfs/file_description.hpp"
  7. #include "gp/vfs/platforms/platform_autopicker.hpp"
  8. #include <atomic>
  9. namespace gp {
  10. enum class process_status {
  11. inactive = 0,
  12. running = 1,
  13. waiting = 2,
  14. finished = 3,
  15. zombie = 4
  16. };
  17. using pid_t = size_t;
  18. struct process_data{
  19. pid_t pid;
  20. gp::function<void()> fn;
  21. void* stack;
  22. size_t stack_sz;
  23. gp::process_status state;
  24. std::atomic_bool is_running;
  25. [[no_unique_address]] gp::specifics::platform_data specifics;
  26. gp::indexed_array<gp::file_description*, gp_config::limits::max_fd_per_process> fds;
  27. process_data(gp::function<void()> _fn, void* _stack, size_t _stack_sz)
  28. : fn(_fn)
  29. , stack(_stack)
  30. , stack_sz(_stack_sz)
  31. , state(gp::process_status::inactive)
  32. , specifics(gp::buffer<char>{(char*)stack, stack_sz})
  33. {}
  34. };
  35. }