Date: Sun, 2 Apr 2000 10:42:13 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Kalum Somaratna aka Grendel cc: DJ Delorie Subject: Re: Allegro and interrupts In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 30 Mar 2000, Kalum Somaratna aka Grendel wrote: > On Wed, 29 Mar 2000 night DOT walker AT tiscalinet DOT it wrote: > > > I must call sin() inside an timer function (i can't use a LUT, would > > be too inaccurate...) I don't know how can i lock the function code > > (without knowing the size) > > IMHO the code executed in a timer interrupt function should be as little > as possible (like setting a flag) and should not hog up too much cpu, > otherwise the whole system will slow down > > Slow instructions like sin should IMHO not be used in a interrupt > function I fail to see how FSIN could be classified as too slow in this context. Even on an i486 it takes less than 300 cycles, which is less than 10 microseconds on a DX-33, 5 usec on DX2-66. The *real* problem is not with using FSIN, but with using any FP instructions at all. If a hardware interrupt handler does that, it needs to save and restore the FPU state (with FNSAVE/FRSTOR instructions), or else the foreground program might produce erroneous results, if it also uses FP instructions. The DJGPP wrappers don't save the FPU context (and neither do other DOS compilers which support the interrupt keyword, AFAIK), so the handler typically must do it.