From e94f87b7985baa1075f43faa995a43ab2ded1c1d Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 2 Nov 2021 23:56:47 +0100 Subject: [PATCH] Fix threadSwitch --- core/thread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/thread.c b/core/thread.c index 42ab230..0aa406d 100644 --- a/core/thread.c +++ b/core/thread.c @@ -132,11 +132,11 @@ struct cpu_state *threadSwitch(struct cpu_state *prevCpu) disable_IRQs(flags); nextThread = threadSelectNext(); + currentThread->cpuState = prevCpu; if (nextThread != currentThread) { - currentThread->cpuState = prevCpu; - currentThread->state = READY; - currentThread = nextThread; - currentThread->state = RUNNING; + currentThread->state = READY; + currentThread = nextThread; + currentThread->state = RUNNING; threadPrepareContext(nextThread); }