www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/15/08:35:30

Date: Thu, 15 Apr 1999 15:32:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alberto Chessa <achessa AT fiar DOT finmeccanica DOT it>
cc: djgpp AT delorie DOT com
Subject: Re: signal & seitimer
In-Reply-To: <01be8729$2599d500$92c809c0@chessa>
Message-ID: <Pine.SUN.3.91.990415152202.5349C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 15 Apr 1999, Alberto Chessa wrote:

> I'm writing a simple multi-threading C++ library and I'm trying to use
> alarm/setitimer for preemptive rescheduing. It works only with "big"
> interval timer value (>1sec). Lower values works for the first 1/4 timeout
> expirations (depending on interval timer value - 10..90ms), then it simple
> stop to call the signal handler (but the program - the last thread - still
> running - the resched counter stop).

Which version of DJGPP are you using (please always mention that when you 
report problems with library functions)?  If you are using v2.02, then 
you should know that `setitimer' from the stock v2.02 distribution is 
buggy.  I have a corrected version that I can send you.

>   setsignal(SIGALRM, Handler);	// It's really required ?

It is not required in DJGPP to reinstall the handler, but other systems 
may reset the handler to SIG_IGN or SIG_DFL, so you might need it there.

(I understand you used `signal', not `setsignal'.)

> Setup()
> {
>   setsignal(SIGALRM, Handler);
>   seitime( 10ms );	// off course, I really feel both it_value and it_interval

10ms is way too small, since the basic timer tick happens every 55ms.  
The code should still work, even with 10ms, but any value less than 55ms 
means that your program will reschedule every 55ms.

> - I lock all the critical kernel code (cotext switching, rescheduling
> routine, signal handler)
> - I lock all kernel data used by rescheduling routine and signal handler

You don't really need this, since the DJGPP implementation of signals 
defers the signal delivery until the program is in its usual foreground 
task, out of the interrupt handler.  But locking cannot hurt.

> - I'm using DJGPP 2.8.1

This is the version of GCC, not of DJGPP.  The version of DJGPP is 
encoded in the djdevNNN.zip name: djdev202.zip means version 2.02.

> - I try under Win95B, both dos-box and command prompt only

This might give you some problems in the DOS box, since Windows sometimes 
forcibly reprograms the timer.  But if you see the same problems in plain 
DOS mode, this is not the cause of the problems.

- Raw text -


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