FP contexts

Till Straumann strauman at slac.stanford.edu
Mon Jun 9 04:57:32 UTC 2008


Leon Pollak wrote:
> Hello, all.
>
> A small question:
>
> I have VERY small amount of FP calculations (which occur also rare) in my 
> application.
>
> Is it safe not to create tasks with FP attribute, but to surround FP 
> calculations with disable/enable interrupts?
>   
If you only have one single task that uses the FPU
then you're OK without disabling/enabling interrupts.

If there is at least one other, FP-enabled task then
disabling/enabling interrupts may still result in corruption
(if your target does lazy FP-context switching).

In general, I consider this very bad practice. IMO, FP-disabled
tasks should execute with the FPU hardware disabled.
So should exception handlers and ISRs (unless they save-restore
FP regs).

Here's one lesson I learned:

I have seen gcc versions which would silently/implicitly
use the FPU so that making all tasks FP tasks was the only
solution. With this gcc version (don't remember which one it
was) I occasionally had problems with gcc implicitly generating
FP code in ISRs. Only my paranoia (I have the FPU *only* enabled
when FP tasks execute, disabled during exceptions, non-FP tasks
etc.) saved me (I got a trap/exception instead of mysterious
corruption and could then figure out a work-around)...

FWIW
-- Till
> Thanks ahead.
>   




More information about the users mailing list