Mail Archives: djgpp/2001/08/29/07:54:42
On Wed, 29 Aug 2001, Rafal Maj wrote:
> 2) Multitasking... currenty I'm using alarm() to prevent system hangs... but
> I don't now how to implement or sikmulate multitasking... if I can only now
> adress (processor state as in longjump) of instruction that was
> about to execute when sigalrm was rised...
The DJGPP signal-handling machinery already saves this information for
you, you just need to know where to look ;-)
Specifically, #include <setjmp.h> and <sys/exceptn.h>, and then use
the variable __djgpp_exception_state, which is an instance of jmp_buf.
The signal-handling code saves in that variable the entire processor
state when the alarm went off. So you can later longjmp using
__djgpp_exception_state, examine the EIP value, etc. For examples of
using this info, see the file dpmiexcp.c in the library sources
(djlsr203.zip).
> why SIGALRM has only 1 sec resolution ?
One word: compatibility.
> Can I rise some signals in regular
> time spaces less then 1 sec ?
Yes; use setitimer instead of alarm. It has the 54-millisecond
resolution of the system clock.
- Raw text -