Menu

#2349 Implement the POSIX interface to high-resolution timers

WSL
closed
Feature
accepted
IINR_-_Include_In_Next_Release
False
2017-12-16
2017-08-13
Anton
No

Please, consider implementation of the POSIX interface to high-resolutin timers:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

It will facilitate simple manual profiling and be useful in other situations that require precise measurement of time.

3 Attachments

Discussion

  • Keith Marshall

    Keith Marshall - 2017-08-13
    • labels: --> posix enhancement
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
     Please, consider implementation of the POSIX interface to high-resolutin timers:
    -https://manned.org/clock_gettime.3posix
    +http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
    
     It will facilitate simple manual profiling and be useful in other situations that require precise measurement of time.
    
    • status: unread --> open
    • assigned_to: Keith Marshall
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1,2 @@
    +posix-clock-api.patch (20.9 kB; text/x-diff)
    +posix-clock-tests.patch (5.0 kB; text/x-diff)
    
     
  • Keith Marshall

    Keith Marshall - 2017-08-13

    Thanks. I've attached patches, to add a tentative implementation, and one-shot autotest checks, for CLOCK_REALTIME and CLOCK_MONOTONIC support; I've also provided source for a continuous, non-terminating test program, to exercise these clocks until interrupted by a console break.

    Do please note that this proposed CLOCK_REALTIME implementation will achieve no better precision than the existing gettimeofday() API; expectations of sub-millisecond resolution of the time-of-day clock, on Windows, is likely a forlorn hope. Similarly, the proposed CLOCK_MONOTONIC implementation will achieve no better than the resolution of the system performance counter API.

    Just one point: when requesting POSIX feature enhancements, please refer directly to the official POSIX.1 specification, rather than to some third party reproduction. I've replaced your original third party reference accordingly.

     

    Last edit: Keith Marshall 2017-08-13
  • Keith Marshall

    Keith Marshall - 2017-08-13
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,2 +1,3 @@
    +clocktest.c (4.0 kB; text/x-csrc)
     posix-clock-api.patch (20.9 kB; text/x-diff)
     posix-clock-tests.patch (5.0 kB; text/x-diff)
    
     
  • Anton

    Anton - 2017-08-13

    Thank you, Keith. I will soon try your patches. I also sent notice about this requiest to the mailing list via Gmane, but has not come through yet.

     

    Last edit: Anton 2017-08-13
    • Keith Marshall

      Keith Marshall - 2017-08-13

      It arrived in my inbox. Gmane seems to be in a state of flux, at present; for a while, it wasn't working at all, and I don't think it has yet recovered its former reliability.

       
  • Keith Marshall

    Keith Marshall - 2017-08-13

    I'm inclined to support this request, (and not just because I already have a tentative implementation "ready to go"). We have provided the POSIX.1 gettimeofday() API, since Danny Smith added it in 2006. As of POSIX.1-2008, this gettimeofday() API has been declared "obsolescent", (and thus likely to be dropped from the next formal release of POSIX.1); its recommended replacement is the clock_gettime() API, operating on the CLOCK_REALTIME timing entity, so it would seem sensible for us to support this.

     
  • Keith Marshall

    Keith Marshall - 2017-12-16
    • status: open --> closed
    • Resolution: none --> accepted
    • Category: Unknown --> IINR_-_Include_In_Next_Release
     
  • Keith Marshall

    Keith Marshall - 2017-12-16

    I committed [ecc51c], for inclusion in the upcoming mingwrt-5.1 release.

     

    Related

    Commit: [ecc51c]

MongoDB Logo MongoDB