@brief 每个 CPU 核心的局部数据
| 21 | |
| 22 | /// @brief 每个 CPU 核心的局部数据 |
| 23 | struct PerCpu { |
| 24 | /// 核心 ID |
| 25 | size_t core_id{0}; |
| 26 | |
| 27 | /// 当前运行的任务 |
| 28 | TaskControlBlock* running_task{nullptr}; |
| 29 | /// 空闲任务 |
| 30 | TaskControlBlock* idle_task{nullptr}; |
| 31 | /// 调度数据 (RunQueue) 指针 |
| 32 | CpuSchedData* sched_data{nullptr}; |
| 33 | |
| 34 | /// @name 构造/析构函数 |
| 35 | /// @{ |
| 36 | explicit PerCpu(size_t id) : core_id(id) {} |
| 37 | |
| 38 | PerCpu() = default; |
| 39 | PerCpu(const PerCpu&) = default; |
| 40 | PerCpu(PerCpu&&) = default; |
| 41 | auto operator=(const PerCpu&) -> PerCpu& = default; |
| 42 | auto operator=(PerCpu&&) -> PerCpu& = default; |
| 43 | ~PerCpu() = default; |
| 44 | /// @} |
| 45 | } __attribute__((aligned(SIMPLEKERNEL_PER_CPU_ALIGN_SIZE))); |
| 46 | |
| 47 | static_assert(sizeof(PerCpu) <= SIMPLEKERNEL_PER_CPU_ALIGN_SIZE, |
| 48 | "PerCpu size should not exceed cache line size"); |