Page 1 of 1
Exception 7 - CoProcessor
Posted: Tue Oct 25, 2005 11:00 pm
by prajwal
I'm getting Exception 7 when trying to Use CoProcessor (80287/387) after doing Context Switch... Reason it says is that the context of CoProcessor is not changed...
How to do this? Where will I get Info on this
Re: Exception 7 - CoProcessor
Posted: Tue Oct 25, 2005 11:00 pm
by JAAman
after a context switch the CPU will throw an exception when executing a FPU instruction
the reason for this is so that the OS can switch the context of the FPU for the next process -- and the context doesn't need to be changed on every task-swap because most processes wont use the FPU (or use it only occasionally)
Re: Exception 7 - CoProcessor
Posted: Wed Oct 26, 2005 11:00 pm
by prajwal
If at all the FPU is used after context switch, then is it necessary to change
the FPU context? if Yes how to do this?
I'm using GCC compiler to compile the OS code.... the GCC would have
generated instuctions telling CPU to use FPU. Is there any option to GCC
telling not to generate code to use CoProcessor.
Re: Exception 7 - CoProcessor
Posted: Thu Oct 27, 2005 11:00 pm
by JAAman
normally the FPU is not used much in the kernel, though it may depend on what your doing
GCC will only generate FPU statements if you are doing floating point math
you can switch the FPU context by saving and restoring the registers just like you do with the CPU context but there are some instructions to help you though i can't remember what they are right now (check intel vol.3)
Re: Exception 7 - CoProcessor
Posted: Thu Oct 27, 2005 11:00 pm
by prajwal
Thanks for clarifying my doubt
Re: Exception 7 - CoProcessor
Posted: Wed Nov 02, 2005 12:00 am
by Da_Maestro
When you change contexts, you can set a flag to tell the processor that you are changing the FPU context. I've forgotten which flag this is (NT?). When you set that, the CPU won't through exception 7. But remember this means that you have to change FPU context on every context switch. On older processors this can get intensive....
Re: Exception 7 - CoProcessor
Posted: Wed Nov 02, 2005 12:00 am
by JAAman
no its not NT (which is in the FLAGS register)
its TS (which is in CR0)
check exception 7: vol.3, pg 5-29
and
CR0.TS: vol.3, pg 2-14
Re: Exception 7 - CoProcessor
Posted: Thu Nov 03, 2005 12:00 am
by prajwal
Where can I get this Info (links) online "check exception 7: vol.3, pg 5-29 "
Intel Programmers Refermce manual says to go thru
Intel System Software Writers Guide to see a sample of Changing
FPU Context on Exception 7.
But I Serached to my level best for Intel System Software Writers Giude on net...
I didn't find....
Where can i get this....?
Re: Exception 7 - CoProcessor
Posted: Thu Nov 03, 2005 12:00 am
by JAAman
not sure, never heard of "intel system software writers guide"
the references i gave were for
IA-32 Intel Architecture Software Developer's Manual:
Volume 3:System Programming Guide
section 5
page 29
and
IA-32 Intel Architecture Software Developer's Manual:
Volume 3:System Programming Guide
section 2
page 14