[Mesa-dev] [PATCH] gallium/os: use CLOCK_MONOTONIC for sleeps

Grazvydas Ignotas notasas at gmail.com
Mon Jul 18 15:03:27 UTC 2016


On Mon, Jul 18, 2016 at 3:14 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/gallium/auxiliary/os/os_time.c | 15 +++++++++++++--
>  src/gallium/auxiliary/os/os_time.h |  4 ----
>  2 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c
> index 3d2e416..633ee3d 100644
> --- a/src/gallium/auxiliary/os/os_time.c
> +++ b/src/gallium/auxiliary/os/os_time.c
> @@ -81,19 +81,30 @@ os_time_get_nano(void)
>  }
>
>
> -#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
>
>  void
>  os_time_sleep(int64_t usecs)
>  {
> +#if defined(PIPE_OS_LINUX)
> +   struct timespec time; \
> +   time.tv_sec = usecs / 1000000; \
> +   time.tv_nsec = (usecs % 1000000) * 1000; \
> +   clock_nanosleep(CLOCK_MONOTONIC, 0, &time, NULL); \

Maybe handle EINTR while you're at it?

Gražvydas


More information about the mesa-dev mailing list