delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/04/23/17:07:50

X-Spam-Check-By: sourceware.org
Message-ID: <444BEC97.5030502@cwilson.fastmail.fm>
Date: Sun, 23 Apr 2006 17:07:35 -0400
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Thunderbird 1.5.0.2 (Windows/20060308)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Support for older OS's
References: <1145646573 DOT 7213 DOT 259631146 AT webmail DOT messagingengine DOT com> <20060421204231 DOT GB27541 AT calimero DOT vinschen DOT de> <444BE7F2 DOT 6060209 AT cwilson DOT fastmail DOT fm> <444BE9AF DOT 2040106 AT gmail DOT com>
In-Reply-To: <444BE9AF.2040106@gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Alexander J. Herrmann wrote:
> Sleep(n)  makes n second delays (Windoze) while sleep(n) make n 
> millisecond delays and beside this you got usleep on some systems.

No, it doesn't.  I just said I had actually looked at the msdn 
documentation.  From

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/sleep.asp
-------------------------------------------
VOID WINAPI Sleep(
   DWORD dwMilliseconds
);

dwMilliseconds
     [in] The minimum time interval for which execution is to be 
suspended, in milliseconds.

     A value of zero causes the thread to relinquish the remainder of 
its time slice to any other thread of equal priority that is ready to 
run. If there are no other threads of equal priority ready to run, the 
function returns immediately, and the thread continues execution.

     A value of INFINITE indicates that the suspension should not time out.
-------------------------------------------


OTOH, sleep() is defined by POSIX thus:

http://www.opengroup.org/onlinepubs/000095399/functions/sleep.html
-------------------------------------------
      unsigned sleep(unsigned seconds);

The sleep() function shall cause the calling thread to be suspended from 
execution until either the number of realtime seconds specified by the 
argument seconds has elapsed or a signal is delivered to the calling 
thread and its action is to invoke a signal-catching function or to 
terminate the process. The suspension time may be longer than requested 
due to the scheduling of other activity by the system.
-------------------------------------------


And, I'm well aware of the existence of usleep and nanosleep.  However, 
that is immaterial: I wasn't going to change Sleep(40) to sleep(40) or 
usleep(40) or nanosleep(40).  I was following KB Q124103

http://support.microsoft.com/kb/Q124103/

Which specifically directs using the following code:

	......
       // Change current window title.
        SetConsoleTitle(pszNewWindowTitle);
        // Ensure window title has been updated.
        Sleep(40);
        // Look for NewWindowTitle.
        hwndFound=FindWindow(NULL, pszNewWindowTitle);
	......

I wasn't going to CHANGE their code; the only confusion was what the 
BEHAVIOR of that code was.  And it turns out, Sleep(40) is 40 milliseconds.

Not 40 seconds like I thought, nor like you claim above.

--
Chuck




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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