-
Notifications
You must be signed in to change notification settings - Fork 5
2017 001 Millisecond sleep
Author: John Reppy
Last revised: May 3, 2017
Status: proposed
Discussion: issue #22
The original specification of OS.Process.sleep left the granularity of the
sleep time unspecified (i.e., operating-system dependent). It was designed
at a time when Unix provided the sleep system call with one-second granularity
and it was expected that some implementations would just define OS.Process.sleep
as an alias for Posix.Process.sleep.
This proposal would tighten the requirements on implementations of both
OS.Process.sleep and Posix.Process.sleep to guarantee at least millisecond
granularity (subject to the whims of operating system scheduling). It also
makes the behavior of Posix.Process.sleep on negative time values consistent
with OS.Process.sleep.
The description of OS.Process.sleep should be replaced with the following:
-
sleep tsuspends the calling process for the time specified byt. Iftis zero or negative, then the calling process does not sleep, but returns immediately; i.e., exception is raised. The granularity of the sleep interval should be one millisecond or finer, although the actual time slept may be longer, owing to system latencies and possible limitations in the timer resolution of the hardware.
and the description of Posix.Process.sleep should be replaced with the following:
-
sleep tcauses the current process to be suspended from execution until eithertseconds have elapsed or until the recipt of a signal that is either caught or that terminates the process. Iftis zero or negative, then the calling process does not sleep, but returns immediately; i.e., exception is raised. Dispite its name, this function should map to the POSIXnanosleepsystem call. The actual time slept may be longer than specified, owing to system latencies and possible limitations in the timer resolution of the hardware.
Provides predictability across implementations without significant implementation
cost. We use one millisecond as the required unit of granularity, since that is
what the Windows Sleep function provides.
