Kernel: refresh task_misbehave()

That function was severely outdated.
This commit is contained in:
apio 2022-10-19 17:26:36 +02:00
parent ef8ba3dec4
commit f3af3e252b
2 changed files with 18 additions and 1 deletions

View File

@ -174,6 +174,14 @@ int main()
} }
else { printf("Success!! Got PID %ld\n", child); } else { printf("Success!! Got PID %ld\n", child); }
child = fork();
if (child < 0)
{
perror("fork");
return 1;
}
if (child == 0) { *(int*)(0xdeadbeef) = 1234; }
int status; int status;
for (;;) for (;;)
{ {

View File

@ -287,8 +287,17 @@ void Scheduler::task_misbehave(Context* context, int64_t status)
{ {
ASSERT(Interrupts::is_in_handler()); ASSERT(Interrupts::is_in_handler());
kdbgln("exit: task %ld misbehaved, used %ld ms of cpu time", sched_current_task->id, sched_current_task->cpu_time); kdbgln("exit: task %ld misbehaved, used %ld ms of cpu time", sched_current_task->id, sched_current_task->cpu_time);
sched_current_task->state = sched_current_task->Exited; if (sched_current_task->id == 1) sched_current_task->state = sched_current_task->Exited;
else
sched_current_task->state = sched_current_task->Dying;
sched_current_task->exit_status = status; sched_current_task->exit_status = status;
if (sched_current_task->id != 1)
{
sched_for_each_child(sched_current_task, [](Task* child) {
if (child->state != child->Exited) child->ppid = 1;
return true;
});
}
task_yield(context); task_yield(context);
} }