| 10 | #include "task_messages.hpp" |
| 11 | |
| 12 | auto TaskManager::Block(CpuSchedData& cpu_sched, ResourceId resource_id) |
| 13 | -> void { |
| 14 | auto* current = GetCurrentTask(); |
| 15 | assert(current != nullptr && "Block: No current task to block"); |
| 16 | assert(current->GetStatus() == TaskStatus::kRunning && |
| 17 | "Block: current task status must be kRunning"); |
| 18 | |
| 19 | auto& list = cpu_sched.blocked_tasks[resource_id]; |
| 20 | if (list.full()) { |
| 21 | klog::Err( |
| 22 | "Block: blocked_tasks list full for resource, cannot block task {}", |
| 23 | current->pid); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | current->fsm.Receive(MsgBlock{resource_id}); |
| 28 | current->aux->blocked_on = resource_id; |
| 29 | list.push_back(current); |
| 30 | |
| 31 | klog::Debug("Block: pid={} blocked on resource={}, data={:#x}", current->pid, |
| 32 | resource_id.GetTypeName(), |
| 33 | static_cast<uint64_t>(resource_id.GetData())); |
| 34 | } |
| 35 | |
| 36 | auto TaskManager::Block(ResourceId resource_id) -> void { |
| 37 | auto& cpu_sched = GetCurrentCpuSched(); |