Skip to content

clock_gettime  #1023

Closed
Closed

Description

clock_gettime with CLOCK_MONOTONIC_RAW does not work.
This is often used on Linux programs to implement functionality similiar to Windows GetTickCount().
e.g. our communication software uses this to implement timeouts which are not affected by time adjustments (NTP).
This should be supported, because WSL claims to run kernel 3.4, but CLOCK_MONOTONIC_RAW is supported since Linux 2.6.28. So even if the software has a fallback to use CLOCK_MONOTONIC (for older kernels), this does not work on WSL.

all other clock_id seems to work correctly.

I've written a test program to verify the results:
clockgettimetest.tar.gz

Actual Results:

clock_gettime(CLOCK_REALTIME) succeeded.
  tv_sec  = 1472631993
  tv_nsec = 935024763
  Wed Aug 31 10:26:33 2016
clock_gettime(CLOCK_REALTIME_COARSE) succeeded.
  tv_sec  = 1472631993
  tv_nsec = 933999685
  Wed Aug 31 10:26:33 2016
clock_gettime(CLOCK_MONOTONIC) succeeded.
  tv_sec  = 2637
  tv_nsec = 48703157
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_MONOTONIC_COARSE) succeeded.
  tv_sec  = 2637
  tv_nsec = 47595751
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_MONOTONIC_RAW) failed: invalid argument
clock_gettime(CLOCK_BOOTTIME) succeeded.
  tv_sec  = 2637
  tv_nsec = 48720981
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_PROCESS_CPUTIME_ID) succeeded.
  tv_sec  = 0
  tv_nsec = 533796
  Thu Jan  1 01:00:00 1970
clock_gettime(CLOCK_THREAD_CPUTIME_ID) succeeded.
  tv_sec  = 0
  tv_nsec = 539759
  Thu Jan  1 01:00:00 1970

Expected Results:

clock_gettime(CLOCK_REALTIME) succeeded.
  tv_sec  = 1472631993
  tv_nsec = 935024763
  Wed Aug 31 10:26:33 2016
clock_gettime(CLOCK_REALTIME_COARSE) succeeded.
  tv_sec  = 1472631993
  tv_nsec = 933999685
  Wed Aug 31 10:26:33 2016
clock_gettime(CLOCK_MONOTONIC) succeeded.
  tv_sec  = 2637
  tv_nsec = 48703157
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_MONOTONIC_COARSE) succeeded.
  tv_sec  = 2637
  tv_nsec = 47595751
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_MONOTONIC_RAW) succeeded.
  tv_sec  = 2637
  tv_nsec = 46079956
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_BOOTTIME) succeeded.
  tv_sec  = 2637
  tv_nsec = 48720981
  Thu Jan  1 01:43:57 1970
clock_gettime(CLOCK_PROCESS_CPUTIME_ID) succeeded.
  tv_sec  = 0
  tv_nsec = 533796
  Thu Jan  1 01:00:00 1970
clock_gettime(CLOCK_THREAD_CPUTIME_ID) succeeded.
  tv_sec  = 0
  tv_nsec = 539759
  Thu Jan  1 01:00:00 1970

Activity

  1. stehufntdev commented on Aug 31, 2016

    @stehufntdev

    Thanks for the detailed steps. I'm closing this out a duplicate of #506 so there's just one post tracking the issue. Please give us feedback on the user voice page so we can prioritize appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions