Scheduler: adjust SSE saving conditions

This commit is contained in:
apio 2022-10-02 19:13:21 +02:00
parent 1ecd24f5d6
commit 38470724dc

View File

@ -272,9 +272,12 @@ void Scheduler::task_yield(Context* context)
sched_current_task = sched_current_task->next_task; sched_current_task = sched_current_task->next_task;
if (sched_current_task->state == sched_current_task->Running) if (sched_current_task->state == sched_current_task->Running)
{ {
if (sched_current_task->id != original_task->id) if (sched_current_task->id != original_task->id || was_idle)
{ {
if (!was_idle && original_task->is_user_task()) { task_save_floating(*original_task); } if (!was_idle && original_task->is_user_task() && original_task->state != original_task->Exited)
{
task_save_floating(*original_task);
}
if (sched_current_task->is_user_task()) { task_restore_floating(*sched_current_task); } if (sched_current_task->is_user_task()) { task_restore_floating(*sched_current_task); }
} }
sched_current_task->task_time = 20; sched_current_task->task_time = 20;
@ -282,7 +285,10 @@ void Scheduler::task_yield(Context* context)
return; return;
} }
} while (sched_current_task != original_task); } while (sched_current_task != original_task);
if (!was_idle && original_task->is_user_task()) task_save_floating(*original_task); if (!was_idle && original_task->is_user_task() && original_task->state != original_task->Exited)
{
task_save_floating(*original_task);
}
sched_current_task = &idle_task; sched_current_task = &idle_task;
sched_current_task->task_time = frequency; sched_current_task->task_time = frequency;
if (!was_idle) { set_context_from_task(*sched_current_task, context); } if (!was_idle) { set_context_from_task(*sched_current_task, context); }