Bugfix: do not crash if we are blocking for no reason
This commit is contained in:
parent
aabff7a1d3
commit
5eae93bbb0
@ -99,6 +99,7 @@ void Scheduler::init()
|
||||
idle_task.regs.rflags = (1 << 21) | (1 << 9);
|
||||
idle_task.task_sleep = 1000;
|
||||
idle_task.user_task = false;
|
||||
idle_task.block_reason = BlockReason::None;
|
||||
idle_task.state = idle_task.Idle;
|
||||
|
||||
strlcpy(idle_task.name, "[cpu-idle]", sizeof(idle_task.name));
|
||||
@ -129,6 +130,7 @@ void Scheduler::add_kernel_task(const char* taskname, void (*task)(void))
|
||||
new_task->cpu_time = 0;
|
||||
strlcpy(new_task->name, taskname, sizeof(new_task->name));
|
||||
append_task(new_task);
|
||||
new_task->block_reason = BlockReason::None;
|
||||
new_task->state = new_task->Running;
|
||||
task_num++;
|
||||
kinfoln("Adding kernel task: %s, starts at %lx, PID %ld, stack at %lx, total tasks: %ld", new_task->name,
|
||||
@ -146,6 +148,7 @@ Task* Scheduler::create_user_task()
|
||||
new_task->task_sleep = 0;
|
||||
new_task->task_time = 0;
|
||||
new_task->cpu_time = 0;
|
||||
new_task->block_reason = BlockReason::None;
|
||||
append_task(new_task);
|
||||
task_num++;
|
||||
return new_task;
|
||||
@ -214,6 +217,7 @@ long Scheduler::load_user_task(const char* filename)
|
||||
new_task->cpu_time = 0;
|
||||
strlcpy(new_task->name, filename, sizeof(new_task->name));
|
||||
append_task(new_task);
|
||||
new_task->block_reason = BlockReason::None;
|
||||
new_task->state = new_task->Running;
|
||||
task_num++;
|
||||
kinfoln("Adding user task: %s, loaded at %lx, PID %ld, stack at %lx, total tasks: %ld", new_task->name,
|
||||
@ -236,6 +240,7 @@ void Scheduler::reset_task(Task* task, ELFImage* new_image)
|
||||
task->regs.rflags = (1 << 21) | (1 << 9); // enable interrupts
|
||||
task->task_sleep = 0;
|
||||
task->cpu_time = 0;
|
||||
task->block_reason = BlockReason::None;
|
||||
kinfoln("Resetting task: %s, loaded at %lx, PID %ld, stack at %lx, total tasks: %ld", task->name, task->regs.rip,
|
||||
task->id, task->regs.rsp, task_num);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void Task::resume()
|
||||
VMM::switch_to_previous_user_address_space();
|
||||
switch (block_reason)
|
||||
{
|
||||
case BlockReason::None: ASSERT(false);
|
||||
case BlockReason::None: return;
|
||||
case BlockReason::Reading: resume_read(); break;
|
||||
case BlockReason::Waiting: resume_wait(); break;
|
||||
|
||||
@ -104,11 +104,11 @@ bool Task::is_still_blocking()
|
||||
{
|
||||
switch (block_reason)
|
||||
{
|
||||
case BlockReason::None: ASSERT(false);
|
||||
case BlockReason::None: return true;
|
||||
case BlockReason::Reading: return is_read_still_blocking();
|
||||
case BlockReason::Waiting: return is_wait_still_blocking();
|
||||
|
||||
default: ASSERT(false);
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user