15 auto* current = GetCurrentTask();
16 assert(current !=
nullptr &&
"Wait: No current task");
18 "Wait: current task status must be kRunning");
27 for (
auto& [task_pid, task] : task_table_) {
29 bool is_child = (task->aux->parent_pid == current->pid);
32 bool pid_match =
false;
33 if (pid ==
static_cast<Pid>(-1)) {
36 }
else if (pid == 0) {
38 pid_match = is_child && (task->aux->pgid == current->aux->pgid);
41 pid_match = is_child && (task->pid == pid);
44 pid_match = is_child && (task->aux->pgid ==
static_cast<Pid>(-pid));
73 "Wait: target task must be kZombie or kExited");
75 "Wait: target parent_pid must match current pid");
77 Pid result_pid = target->
pid;
87 auto it = task_table_.find(target->
pid);
88 assert(it != task_table_.end() &&
89 "Wait: target must exist in task_table");
90 task_table_.erase(it->first);
93 klog::Debug(
"Wait: pid={} reaped child={}", current->pid, result_pid);
106 Block(wait_resource_id);
108 klog::Debug(
"Wait: pid={} blocked on resource={}, data={}", current->pid,
109 wait_resource_id.GetTypeName(),
110 static_cast<uint64_t
>(wait_resource_id.GetData()));