This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Floating Point Register saves




Nick Garnett wrote:

David Brennan <eCos@brennanhome.com> writes:



According to the documentation in the i386 hal cdl documentation, it
states that by default eCos will "save and restore FPU state on every
thread switch, interrupt and exception." It states this in the option
for turning off lazy FPU switching. Our application uses floating
point registers in the DSR context. With Lazy FPU on, we get an
SIGFPE. (Which I guess is not surprising). So we have turned off lazy
FPU switching. With lazy FPU off, is it safe to use floating points in
DSR (or ISR) context? (We got burned by this earlier under VxWorks.)



In theory using the FPU in ISRs and DSRs is allowed, there is code to save and restore the FPU state in both lazy and non-lazy configurations. Of course this has not been exercised very much and may contain bugs. You may have to some debugging.

However, I would also question the need to do FP operations in ISRs
and DSRs. These routines are meant to be fast and small. It is often
better to offload any complex computations to a thread. Note that even
if the DSR only does a small amount of FP computation, the cost of
saving and restoring the FP state to let it do so is very high.




Ok, I doubt that we can use floating points in a ISR context with lazy FPU switching, since lazy FPU switching actually relies on an exception being caught. (But interrupts will be disabled.) So for now we turned off lazy FPU switching. We only install one interrupt driver, and it runs at a nominally slow 40 Hz (on a 1Ghz Celeron). However, in discussion with the team, we realized that this will also affect the Ethernet driver which probably did not need it. So we may be going back to some other method. Which brings up the point, is there something like HAL_FPU_SAVE which is standard for needing to do an FPU save/restore? And can would this "register" with the FPU to prevent the Floating Point Exception?

As for using floating points in DSR context, we have a rich C++ wrapper around the operating system so our application rarely (if ever) needs to make OS calls. This wrapper uses floating point timers. (Actually internally they are done in ticks, but the external access is in seconds.) Therefore, if I need to access a timer (even to check its value, or see if it has timed out, we end up using floating points.)

Thanks
David Brennan


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]