This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Support for older OS's


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]