comments
authorSimon Marlow <marlowsd@gmail.com>
Thu, 7 Feb 2013 10:00:09 +0000 (10:00 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 7 Feb 2013 10:00:09 +0000 (10:00 +0000)
rts/win32/IOManager.c

index 65f5d4c..0091f23 100644 (file)
@@ -199,7 +199,17 @@ IOWorkerProc(PVOID param)
                    /* Approximate implementation of threadDelay;
                     * 
                     * Note: Sleep() is in milliseconds, not micros.
-                    */
+                     *
+                     * MSDN says of Sleep:
+                     *   If dwMilliseconds is greater than one tick
+                     *   but less than two, the wait can be anywhere
+                     *   between one and two ticks, and so on.
+                     *
+                     * so we need to add (milliseconds-per-tick - 1)
+                     * to the amount of time we sleep for.
+                     *
+                     * test ThreadDelay001 fails if we get this wrong.
+                     */
                    Sleep(((work->workData.delayData.usecs + 999) / 1000) + iom->sleepResolution - 1);
                    len = work->workData.delayData.usecs;
                    complData = NULL;