MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / Block

Method Block

src/task/block.cpp:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "task_messages.hpp"
11
12auto 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
36auto TaskManager::Block(ResourceId resource_id) -> void {
37 auto& cpu_sched = GetCurrentCpuSched();

Callers 2

sys_futexFunction · 0.80
LockMethod · 0.80

Calls 6

ErrFunction · 0.85
DebugFunction · 0.85
ReceiveMethod · 0.80
GetTypeNameMethod · 0.80
GetDataMethod · 0.80
GetStatusMethod · 0.45

Tested by

no test coverage detected