Date: Thu, 15 Apr 1999 14:21:33 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: "Miguel A. Ordorica V." cc: djgpp AT delorie DOT com Subject: Re: Is it possible...? In-Reply-To: <000b01be86e8$b48062c0$d193e994@df1.telmex.net.mx> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 14 Apr 1999, Miguel A. Ordorica V. wrote: > I'm working on a program that needs to copy a large block of = > data (approximately 1MB) to a different memory location every time a = > specific time period has passed, and record the elapsed program time. To = > that effect, I have tried reprogramming the timer interrupt and doing = > the copy inside the interrupt handler, but I've had some problems = > because the copy takes too much time and so my handler misses the next = > event, screwing up my timekeeping and other parts of the program. Use the SIGALRM signal instead of the interrupt. Set up a handler for that signal, and then call either `alarm' or `setitimer' with the interval you need. When the time passes, these functions raise the SIGALRM signal, and your handler is called. You just need to move the data inside the handler. The advantage of this approach is that you don't need to hook the timer tick (the library does that for you), and you don't disrupt the system clock operation, since the signal is delivered *after* the timer tick is handled by the normal handler. > After reading a bit, I found an interesting technique: you pop = > the contents of the stack until you reach the return address used by the = > iret instruction, and insert the return address of the copy function, = > then push back all the values you had just popped. The ``interesting techniques'' are for those who don't have timer facilities built into the library. DJGPP does.