]> Zhao Yanbai Git Server - minix.git/commitdiff
enable_fpu_exception() - only write cr0 if bit isn't already on.
authorBen Gras <ben@minix3.org>
Wed, 22 Sep 2010 14:31:06 +0000 (14:31 +0000)
committerBen Gras <ben@minix3.org>
Wed, 22 Sep 2010 14:31:06 +0000 (14:31 +0000)
(NMI profiling results indicate this both is relatively expensive and
happens a lot unnecessarily if the fpu is in use.)

kernel/arch/i386/exception.c

index 86eb541011aa54ab29f79d0f55944c86096c2baf..7b3e1e37854006c21a389f8d6a13be8f8b5f2644 100644 (file)
@@ -285,7 +285,9 @@ PUBLIC void proc_stacktrace(struct proc *whichproc)
 
 PUBLIC void enable_fpu_exception(void)
 {
-       write_cr0(read_cr0() | I386_CR0_TS);
+       u32_t cr0 = read_cr0();
+       if(!(cr0 & I386_CR0_TS))
+               write_cr0(cr0 | I386_CR0_TS);
 }
 
 PUBLIC void disable_fpu_exception(void)