From 38470724dc117ea377e83b952bc520d67c23e846 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 2 Oct 2022 19:13:21 +0200 Subject: [PATCH] Scheduler: adjust SSE saving conditions --- kernel/src/thread/Scheduler.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index b630e033..613557dc 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -272,9 +272,12 @@ void Scheduler::task_yield(Context* context) sched_current_task = sched_current_task->next_task; 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); } } sched_current_task->task_time = 20; @@ -282,7 +285,10 @@ void Scheduler::task_yield(Context* context) return; } } 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->task_time = frequency; if (!was_idle) { set_context_from_task(*sched_current_task, context); }