Mail Archives: djgpp/1999/04/15/07:25:08
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.
- Raw text -