* @brief 每个核心的调度数据 (RunQueue) */
| 32 | * @brief 每个核心的调度数据 (RunQueue) |
| 33 | */ |
| 34 | struct CpuSchedData { |
| 35 | SpinLock lock{"sched_lock"}; |
| 36 | |
| 37 | /// 调度器数组 (按策略索引) |
| 38 | std::array<etl::unique_ptr<SchedulerBase>, |
| 39 | static_cast<uint8_t>(SchedPolicy::kPolicyCount)> |
| 40 | schedulers{}; |
| 41 | |
| 42 | /// 睡眠队列 (优先队列,按唤醒时间排序) |
| 43 | etl::priority_queue< |
| 44 | TaskControlBlock*, kernel::config::kMaxSleepingTasks, |
| 45 | etl::vector<TaskControlBlock*, kernel::config::kMaxSleepingTasks>, |
| 46 | TaskControlBlock::WakeTickCompare> |
| 47 | sleeping_tasks; |
| 48 | |
| 49 | /// 阻塞队列 (按资源 ID 分组) |
| 50 | etl::unordered_map< |
| 51 | ResourceId, |
| 52 | etl::list<TaskControlBlock*, kernel::config::kMaxBlockedPerGroup>, |
| 53 | kernel::config::kMaxBlockedGroups, |
| 54 | kernel::config::kMaxBlockedGroupsBuckets> |
| 55 | blocked_tasks; |
| 56 | |
| 57 | /// Per-CPU tick 计数 (每个核心独立计时) |
| 58 | uint64_t local_tick{0}; |
| 59 | |
| 60 | /// 本核心的空闲时间 (单位: ticks) |
| 61 | uint64_t idle_time{0}; |
| 62 | |
| 63 | /// 本核心的总调度次数 |
| 64 | uint64_t total_schedules{0}; |
| 65 | |
| 66 | /// Schedule() 是否已被显式调用 |
| 67 | bool scheduler_started{false}; |
| 68 | |
| 69 | /// @name 构造/析构函数 |
| 70 | /// @{ |
| 71 | CpuSchedData() = default; |
| 72 | CpuSchedData(const CpuSchedData&) = delete; |
| 73 | CpuSchedData(CpuSchedData&&) = delete; |
| 74 | auto operator=(const CpuSchedData&) -> CpuSchedData& = delete; |
| 75 | auto operator=(CpuSchedData&&) -> CpuSchedData& = delete; |
| 76 | ~CpuSchedData() = default; |
| 77 | /// @} |
| 78 | }; |
| 79 | |
| 80 | /** |
| 81 | * @brief 任务管理器 |
nothing calls this directly
no outgoing calls
no test coverage detected