www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/29/06:15:08

Date: Wed, 29 Aug 2001 12:07:11 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Raf256 <rmaj AT mail DOT pgd DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: Timer interrupt ?
In-Reply-To: <9mh6j2$jql$1@news.tpi.pl>
Message-ID: <Pine.SUN.3.91.1010829115832.15631K-100000@is>
MIME-Version: 1.0
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

On Wed, 29 Aug 2001, Raf256 wrote:

> I have following problem - I'm using alarm() and to detect infinite (or to
> long) loops, handler of sigalrm makes long jump to special funcion that
> informs tahat program probably had hanged.
> Q#1 can I make long jump to instruction that was going to execute when
> signal was rised ?

What do you mean by ``jump to the instruction''?  You don't know what 
instruction was running when the alarm fired.

If you mean you want your SIGALRM handler to simply return, then yes, you 
can--but why would you want to?  If the program hangs, what sense does it 
make to let it continue hanging?

> Q#2 but alarm wan't work in f(;;), AFAIR because this loop doesn't touch any
> data...

Then don't do that ;-)  It shouldn't be hard, in a real-life program, to 
touch some variable inside a loop.

> I think taht timer interrupt 1C might help...

No, it won't: you cannot deliver an asynchronous signal off a hardware 
interrupt (Int 1Ch is a software interrupt, but it's treated by the DPMI 
host as a hardware interrupt).

> Q#3 How should I lock memory in this example ? I heard that all data touched
> in signal handler should be atomic_t but I need jum_buf...

You don't need to worry about that in DJGPP.  A SIGALRM handler could 
touch any data, and that data doesn't have to be locked.

> Q#4 In FAQ it is written that it's impossible to determinate size of C/C++
> function ? But Allegro is doing this simply by putting empty function right
> after original function and checking it's adress...

This is a kludge which is not guaranteed to work.

- Raw text -


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