Mail Archives: djgpp/2001/08/29/06:15:08
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 -