delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/06/26/16:26:59

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Mon, 26 Jun 2000 16:24:42 -0400 (EDT)
From: "Ashif S. Harji" <asharji AT plg2 DOT math DOT uwaterloo DOT ca>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: setitimer with values less than 1000 microseconds
Message-ID: <Pine.SOL.3.96.1000626160406.15430A-100000@plg2.math.uwaterloo.ca>
MIME-Version: 1.0

When I use setitimer with a value less than 1000 microseconds, no
sigalrms are generated.  Consider the following program:

#include <sys/time.h> 
#include <signal.h>

int alarm( int sig ) {
}

int main() {
    itimerval it; 

    it.it_interval.tv_sec = 0;
    it.it_interval.tv_usec = 0; 

    it.it_value = (timeval){ 0,   // seconds
                             10 }; // microseconds
    signal( SIGALRM, (void (*)(int))alarm ); 

    setitimer( ITIMER_REAL, &it, (itimerval *)0 ); // set the alarm clock
to go off
    sigpause( 0 );  

} //

It simply hangs unless I use a timer value of 1000 microseconds or higher. 
When I run this program on a linux or sun sparc machine, it works fine. 
The difference seems to be that on these machines the timer value is
rounded up to the nearest resolution value.  However, with cygwin the
values are rounded down.  That is in the source code for setitimer in
window.cc: 

  elapse = itv.it_value.tv_sec * 1000 + itv.it_value.tv_usec / 1000; 
  if (elapse == 0) 
    return 0; 
  if (!(timer_active = SetTimer (gethwnd(), 1, elapse, NULL))) 
    {
      __seterrno (); 
      return -1; 
    }

elapse evaluates to 0 for values less than 1000 microseconds.  Thus, for
small time values, the timer is simply killed.  Is it possible to changes
this so that small time values are rounded up to the smallest resolution?

thanks,
ashif harji


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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