Date: Thu, 18 Jul 2002 07:44:11 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: djgpp AT delorie DOT com Subject: Re: Logging data from an interrupt to a file 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 Wed, 17 Jul 2002, Thomas Harte wrote: > My problem is that although logging to a memory buffer is nice, I would like > to log to disc. But I can't find a way to do this, assuming that I don't > have the memory to log all keypresses and then write them to disc when the > second program terminates. > > What would I do to achieve this? Make the interrupt handler set a flag when the memory buffer is almost full, and make the main foreground function of your logger look at the flag and write out the buffer when the flag is set; then reset the flag. The interrupt handler should notice that the flag went from set to reset, and start recording keys from the beginning of the buffer. If you use this method, be sure to disable interrupts around code, both in the foreground code and in the interrupt handler, which accesses the flag and the buffer pointer, to prevent the two parts stepping on each other's toes.