Mail Archives: djgpp/2002/09/10/01:42:28
Viestissä Tiistai 10 Syyskuu 2002 06:12, Charles Sandmann kirjoitti:
> > I have a program that uses setitimer to raise periodic SIGALRM signals.
> > The ANSI C/C++ spec guarantees very little about what can be done in a
> > signal handler. However, I've discovered that djgpp 2.03 / gcc 3.10
> > don't save/restore the FPU state across an async signal handler.
> > Consequently if the foreground and the signal handler both execute simple
> > floating points ops (like multiply) then the foreground routine can be
> > trashed.
>
> Not all systems have FPUs. The save/restore instructions are expensive,
> and even more expensive if they must be emulated. Floating point
> calcs in a signal handler are very rare. So adding this would put a big
> burden on machines which can least afford it.
>
> > I've added some inline assembler (fnsave/frstor) around my signal handler
> > to solve this.
>
> Good, I think this is the right thing to do.
>
> > Perhaps the FAQ could be updated to include this info or even
> > better if libc could include this for async signals.
>
> I'd vote yes for documentation (info libc someplace). No for FAQ, since
> it's the first time it's come up that I know about, and Eli's busy :-)
Maybe not all who have used similar things have send a note to mailing lists.
For example I have used FPU in hardware interrupt handler (that time RTC
periodic interrupts with frequency 512Hz) from DJGPP application for real
time ADC data processing. Of course it was evident for me that I should save
FPU state in interrupt handler.
Also an example how to do that is available in sources of libgdb.a
(dbgcom.c)
Andris
- Raw text -