delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/10/01:42:28

From: Andris <pavenis AT lanet DOT lv>
Organization: Pavenis
To: djgpp AT delorie DOT com
Subject: Re: SIGALRM signal handler doesn't save FPU state
Date: Tue, 10 Sep 2002 05:36:14 +0300
User-Agent: KMail/1.4.7
References: <q78f9.1851$Yc7 DOT 106506 AT newsfep2-gui> <3d7d6309 DOT sandmann AT clio DOT rice DOT edu>
In-Reply-To: <3d7d6309.sandmann@clio.rice.edu>
MIME-Version: 1.0
Message-Id: <200209100536.14662.pavenis@lanet.lv>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g8A5YMJ11667
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019