delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/06/26/18:33:21

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
From: Chris Faylor <cgf AT cygnus DOT com>
Date: Mon, 26 Jun 2000 18:32:37 -0400
To: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: setitimer with values less than 1000 microseconds
Message-ID: <20000626183237.B5675@cygnus.com>
Reply-To: cygwin AT sourceware DOT cygnus DOT com
Mail-Followup-To: cygwin AT sourceware DOT cygnus DOT com
References: <Pine DOT SOL DOT 3 DOT 96 DOT 1000626160406 DOT 15430A-100000 AT plg2 DOT math DOT uwaterloo DOT ca>
Mime-Version: 1.0
User-Agent: Mutt/1.2i
In-Reply-To: <Pine.SOL.3.96.1000626160406.15430A-100000@plg2.math.uwaterloo.ca>; from asharji@plg2.math.uwaterloo.ca on Mon, Jun 26, 2000 at 04:24:42PM -0400

On Mon, Jun 26, 2000 at 04:24:42PM -0400, Ashif S. Harji wrote:
>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?

Your analysis of the problem is correct, IMO.  I'm going to check in the
following change to cygwin to work around this problem.

Thanks very much for tracking this down so precisely.

cgf

Index: window.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/window.cc,v
retrieving revision 1.4
diff -u -p -r1.4 window.cc
--- window.cc   2000/05/09 13:28:11     1.4
+++ window.cc   2000/06/26 22:31:00
@@ -176,7 +176,10 @@ setitimer (int which, const struct itime
   itv = *value;
   elapse = itv.it_value.tv_sec * 1000 + itv.it_value.tv_usec / 1000;
   if (elapse == 0)
-    return 0;
+    if (itv.it_value.tv_usec)
+      elapse = 1;
+    else
+      return 0;
   if (!(timer_active = SetTimer (gethwnd(), 1, elapse, NULL)))
     {
       __seterrno ();

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