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

Method ReapTask

src/task/task_manager.cpp:260–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260auto TaskManager::ReapTask(TaskControlBlock* task) -> void {
261 if (!task) {
262 return;
263 }
264
265 // 确保任务处于僵尸或退出状态
266 if (task->GetStatus() != TaskStatus::kZombie &&
267 task->GetStatus() != TaskStatus::kExited) {
268 klog::Warn("ReapTask: Task {} is not in zombie/exited state", task->pid);
269 return;
270 }
271
272 // Capture pid before erase (unique_ptr deletes on erase)
273 Pid pid = task->pid;
274
275 // 从全局任务表中移除 (unique_ptr auto-deletes TCB)
276 {
277 LockGuard lock_guard{task_table_lock_};
278 task_table_.erase(pid);
279 }
280
281 klog::Debug("ReapTask: Task {} resources freed", pid);
282}
283
284auto TaskManager::ReparentChildren(TaskControlBlock* parent) -> void {
285 if (!parent) {

Callers

nothing calls this directly

Calls 3

WarnFunction · 0.85
DebugFunction · 0.85
GetStatusMethod · 0.45

Tested by

no test coverage detected