Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2000 13:43:22 -0800
From:      "Jonathan Graehl" <jonathan@graehl.org>
To:        <freebsd-hackers@freebsd.org>
Subject:   POSIX clock_gettime, clock_getres return errno invalid argument for CLOCK_PROF and CLOCK_VIRTUAL
Message-ID:  <NCBBLOALCKKINBNNEDDLOELLDHAA.jonathan@graehl.org>

next in thread | raw e-mail | index | archive | help
The resolution (clock_getres) of CLOCK_REALTIME is 783 ns on my
4.2-STABLE/Pentium 2.  Is there a more accurate timer available?
(clearly, gettimeofday is limited to 1000ns resolution ;)

(submitted pr follows)

While there is no problem with CLOCK_REALTIME, POSIX clock_gettime,
clock_getres return errno invalid argument for CLOCK_PROF and
CLOCK_VIRTUAL, which are documented in the man pages (section 2) as
being user+system and user time, respectively.

FreeBSD 3jane 4.2-STABLE FreeBSD 4.2-STABLE #0: Sat Dec  2 14:46:10 PST
2000     root@3jane:/ext/obj/usr/src/sys/NEWJANE  i386

/* demonstrates that the clock_get... calls succed for CLOCK_REALTIME
but fail for CLOCK_PROF and CLOCK_VIRTUAL */
#include <sys/time.h>
#include <stdio.h>

int main() {
  struct timespec t;

  puts("CLOCK_PROF");
  if (clock_gettime(CLOCK_PROF, &t))
    perror(NULL);
  if (clock_getres(CLOCK_PROF, &t))
    perror(NULL);

  puts("\nCLOCK_VIRTUAL");
  if (clock_gettime(CLOCK_VIRTUAL, &t))
    perror(NULL);
  if (clock_getres(CLOCK_VIRTUAL, &t))
    perror(NULL);

  puts("\nCLOCK_REALTIME");
  if (clock_gettime(CLOCK_REALTIME, &t))
    perror(NULL);
  if (clock_getres(CLOCK_REALTIME, &t))
    perror(NULL);
}

Immediate fix: remove mention of CLOCK_VIRTUAL AND CLOCK_PROF from
sys/time.h and man 2 clock_gettime

Real fix: implement the documented POSIX functionality



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?NCBBLOALCKKINBNNEDDLOELLDHAA.jonathan>