diff --git a/sortix/scheduler.cpp b/sortix/scheduler.cpp index 51adfdae..94f2f662 100644 --- a/sortix/scheduler.cpp +++ b/sortix/scheduler.cpp @@ -175,7 +175,8 @@ static void InterruptYieldCPU(CPU::InterruptRegisters* regs, void* /*user*/) static void ThreadExitCPU(CPU::InterruptRegisters* regs, void* /*user*/) { - Float::NofityTaskExit(); // Can't use floating point instructions from now. + // Can't use floating point instructions from now. + Float::NofityTaskExit(currentthread); SetThreadState(currentthread, Thread::State::DEAD); InterruptYieldCPU(regs, NULL); } diff --git a/sortix/x86-family/float.cpp b/sortix/x86-family/float.cpp index 43360433..fa3dffbf 100644 --- a/sortix/x86-family/float.cpp +++ b/sortix/x86-family/float.cpp @@ -75,9 +75,10 @@ void Init() Interrupt::RegisterHandler(7, OnFPUAccess, NULL); } -void NofityTaskExit() +void NofityTaskExit(Thread* thread) { - fputhread = NULL; + if ( fputhread == thread ) + fputhread = NULL; DisableFPU(); } diff --git a/sortix/x86-family/float.h b/sortix/x86-family/float.h index 94b6e19f..014971bb 100644 --- a/sortix/x86-family/float.h +++ b/sortix/x86-family/float.h @@ -26,10 +26,13 @@ #define SORTIX_FLOAT_H namespace Sortix { + +class Thread; + namespace Float { void Init(); -void NofityTaskExit(); +void NofityTaskExit(Thread* thread); static inline void EnableFPU() { @@ -50,5 +53,6 @@ static inline void NotityTaskSwitch() } } // namespace Float + } // namespace Sortix #endif