Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Apr 1996 06:00:01 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        andreas@knobel.gun.de, terry@lambert.org
Cc:        current@FreeBSD.org, j@uriah.heep.sax.de
Subject:   Re: FreeBSD performance vs BSD/OS
Message-ID:  <199603312000.GAA10850@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>If I remember right this was discussed already some months ago and
>the result was, that freebsd has 128 HZ. BTW, I think it was Joerg,
>whi told me that.

HZ is not part of the application interface in BSD.

>And if you run a benchmark like ssba (I think it was this one) that
>tries to figure out HZ itself, then you get values about 128 or 130...

>Perhaps someone else can make this more clear ?! I digged around in
>the kernel sources in microtime and some other places, but didn't find
>the right place...

There are many different real and virtual (timekeeping) clocks with
different frequencies:

- the scheduling clock.  This is a real clock with frequency that
  happens to be 100.  It isn't available to applications.

- the statistics clock.  This is a real clock with frequency that
  happens to  be 128.  It isn't directly available to applications.

- the clock reported by clock(3).  This is a virtual clock with a
  frequency that happens to be 128.  It's actual frequency is given
  by the macro CLOCKS_PER_SEC.  Note that CLOCKS_PER_SEC may be
  floating point.  Don't use clock() in new programs under FreeBSD.
  It is feeble compared with getrusage().  It is provided for ANSI
  conformance.  It is implemented by calling getrusage() and throwing
  away information and resolution.

- the clock reported by times(3).  This is a virtual clock with a
  frequency that happens to be 128.  It's actual frequency is given
  by the macro CLK_TCK (deprecated; don't use) and by
  sysconf(_SC_CLK_TCK) and by sysctl(3).  Note that its frequency
  may be different fro CLOCKS_PER_SEC.  Don't use times() in new
  programs under FreeBSD.  It is feeble compared with gettimeofday()
  together with getrusage().  It is provided for POSIX conformance.
  It is implemented by calling gettimeofday() and getrusage() and
  throwing away information and resolution.

- the profiling clock.  This is a real clock with frequency 1024.
  It is used mainly by moncontrol(3), kgmon(8) and gprof(1).
  Applications should determine its actual frequency using sysctl(3)
  or by reading it from the header in the profiling data file.

- the mc14618a clock.  This is a real clock with a nominal frequency of
  32768.  It is divided down to give the statistic clock and the profiling
  clock.  It isn't available to applications.

- the microseconds clock.  This is a virtual clock with frequency
  1000000.  It is used for most timekeeping in BSD and is exported
  to applications in getrusage(2), gettimeofday(2), select(2),
  getitimer(2), ...  This is the clock that should normally be used
  by BSD applications.

- the i8254 clock.  This is a real clock with a nominal frequency of
  1193182.  It is divided down to give the scheduling clock.  It isn't
  available to applications.

- the i586 clock on i586 systems.  This is a real clock with a frequency
  of up to 200000000.  It is used to interpolate between values of the
  scheduling clock.  It isn't available to applications.

Summary: if "HZ" isn't 1000000 then the application is probably using
the wrong clock.

Bruce



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