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

From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Timer interrupt ?
Date: 29 Aug 2001 07:47:53 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 55
Message-ID: <9mi6n9$8r5$4@antares.lu.erisoft.se>
References: <9mh6j2$jql$1 AT news DOT tpi DOT pl>
NNTP-Posting-Host: merope.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Raf256 (rmaj AT mail DOT pgd DOT pl) wrote:
: Hi,
: I read the FAQ, but I didn't find all answares...
: 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 ? I can use it to display something like : Program hanged,
: [K]ill, [I]gnore  :-)

Not sure but for alarm() I think the answer is yes.

: Q#2 but alarm wan't work in f(;;), AFAIR because this loop doesn't touch any
: data... I think taht timer interrupt 1C might help... can somone PLEASE
: write litle example (it's 10-15 lines probably)...
: Something like :

: jmp_buf jjj;  void handler() { longjmp(jjj,1); }
: main() {  /* install handler ????? */   alarm(5);
:   if (setjmp(handler,1)) return 1;
:   f(;;)
: }

Not sure how timer interrupt 0x1c might help here.

Anyway a (chicken?) way out would be to make sure the loop do touch
some data, like "volatile int dummy; dummy = 0".

: 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...

What's atomic_t? 

For data you just pass in the address and length of it to the right
routine.

The same for code.

For simple examples like this or while you just want to make it work
you can just as well set the approriate startup flag (it's in the FAQ)
and lock the whole program.

: 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...

It's impossible because you can never be sure that the compiler
doesn't move around the functions. There's nothing in C that forbids
this, I think. Right now the allegro way works, but it might be broken
tomorrow.


Right,

						MartinS

- Raw text -


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