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

Method Wakeup

src/task/wakeup.cpp:12–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "task_messages.hpp"
11
12auto TaskManager::Wakeup(CpuSchedData& cpu_sched, ResourceId resource_id)
13 -> void {
14 auto it = cpu_sched.blocked_tasks.find(resource_id);
15
16 if (it == cpu_sched.blocked_tasks.end()) {
17 klog::Debug("Wakeup: No tasks waiting on resource={}, data={:#x}",
18 resource_id.GetTypeName(),
19 static_cast<uint64_t>(resource_id.GetData()));
20 return;
21 }
22
23 auto& waiting_tasks = it->second;
24 size_t wakeup_count = 0;
25
26 while (!waiting_tasks.empty()) {
27 auto* task = waiting_tasks.front();
28 waiting_tasks.pop_front();
29
30 assert(task->GetStatus() == TaskStatus::kBlocked &&
31 "Wakeup: task status must be kBlocked");
32 assert(task->aux->blocked_on == resource_id &&
33 "Wakeup: task blocked_on must match resource_id");
34
35 task->fsm.Receive(MsgWakeup{});
36 task->aux->blocked_on = ResourceId{};
37
38 auto* scheduler =
39 cpu_sched.schedulers[static_cast<uint8_t>(task->policy)].get();
40 assert(scheduler != nullptr && "Wakeup: scheduler must not be null");
41 scheduler->Enqueue(task);
42 wakeup_count++;
43 }
44
45 cpu_sched.blocked_tasks.erase(resource_id);
46
47 klog::Debug("Wakeup: Woke up {} tasks from resource={}, data={:#x}",
48 wakeup_count, resource_id.GetTypeName(),
49 static_cast<uint64_t>(resource_id.GetData()));
50}
51
52auto TaskManager::Wakeup(ResourceId resource_id) -> void {
53 for (size_t i = 0; i < SIMPLEKERNEL_MAX_CORE_COUNT; ++i) {

Callers 1

sys_futexFunction · 0.80

Calls 7

DebugFunction · 0.85
GetTypeNameMethod · 0.80
GetDataMethod · 0.80
emptyMethod · 0.80
ReceiveMethod · 0.80
GetStatusMethod · 0.45
EnqueueMethod · 0.45

Tested by

no test coverage detected