summaryrefslogtreecommitdiff
path: root/static/freebsd/man7/clocks.7 3.html
blob: a984c8b9a71e786e871d60c2b314d7f4f6c1b564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<table class="head">
  <tr>
    <td class="head-ltitle">CLOCKS(7)</td>
    <td class="head-vol">Miscellaneous Information Manual</td>
    <td class="head-rtitle">CLOCKS(7)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">clocks</code> &#x2014; <span class="Nd">various
    system timers</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
  &lt;<a class="In">time.h</a>&gt;</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp"><code class="Dv">HZ</code> is not part of the application
    interface in <span class="Ux">BSD</span>.</p>
<p class="Pp">There are many different real and virtual (timekeeping) clocks
    with different frequencies:</p>
<ul class="Bl-bullet">
  <li>The scheduling clock. This is a real clock with frequency that happens to
      be 100. It is not available to applications.</li>
  <li>The statistics clock. This is a real clock with frequency that happens to
      be 128. It is not directly available to applications.</li>
  <li>The clock reported by <a class="Xr">clock(3)</a>. This is a virtual clock
      with a frequency that happens to be 128. Its actual frequency is given by
      the macro <code class="Dv">CLOCKS_PER_SEC</code>. Note that
      <code class="Dv">CLOCKS_PER_SEC</code> may be floating point. Do not use
      <a class="Xr">clock(3)</a> in new programs under
      <span class="Ux">FreeBSD</span>. It is feeble compared with
      <a class="Xr">getrusage(2)</a>. It is provided for ANSI conformance. It is
      implemented by calling <a class="Xr">getrusage(2)</a> and throwing away
      information and resolution.</li>
  <li id="sysconf">The clock reported by <a class="Xr">times(3)</a>. This is a
      virtual clock with a frequency that happens to be 128. Its actual
      frequency is given by the macro <code class="Dv">CLK_TCK</code>
      (deprecated; do not use) and by
      <a class="permalink" href="#sysconf"><code class="Fn">sysconf</code></a>(<var class="Fa">_SC_CLK_TCK</var>)
      and by <a class="Xr">sysctl(3)</a>. Note that its frequency may be
      different from <code class="Dv">CLOCKS_PER_SEC</code>. Do not use
      <a class="Xr">times(3)</a> in new programs under
      <span class="Ux">FreeBSD</span>. It is feeble compared with
      <a class="Xr">gettimeofday(2)</a> together with
      <a class="Xr">getrusage(2)</a>. It is provided for POSIX conformance. It
      is implemented by calling <a class="Xr">gettimeofday(2)</a> and
      <a class="Xr">getrusage(2)</a> and throwing away information and
      resolution.</li>
  <li>The profiling clock. This is a real clock with frequency 1024. It is used
      mainly by <a class="Xr">moncontrol(3)</a> and <a class="Xr">gprof(1)</a>.
      Applications should determine its actual frequency using
      <a class="Xr">sysctl(3)</a> or by reading it from the header in the
      profiling data file.</li>
  <li>The mc146818a 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 is not available to applications.</li>
  <li>The microseconds clock. This is a virtual clock with frequency 1000000. It
      is used for most timekeeping in <span class="Ux">BSD</span> and is
      exported to applications in <a class="Xr">getrusage(2)</a>,
      <a class="Xr">gettimeofday(2)</a>, <a class="Xr">select(2)</a>,
      <a class="Xr">getitimer(2)</a>, etc. This is the clock that should
      normally be used by <span class="Ux">BSD</span> applications.</li>
  <li>The i8254 clock. This is a real clock/timer with a nominal frequency of
      1193182. It has three independent time counters to be used. It is divided
      down to give the scheduling clock. It is not available to
    applications.</li>
  <li>The TSC clock (64-bit register) on fifth-generation or later x86 systems.
      This is a real clock with a frequency that is equivalent to the number of
      cycles per second of the CPU(s). Its frequency can be found using the
      <var class="Va">machdep.tsc_freq</var> sysctl, if it is available. It is
      used to interpolate between values of the scheduling clock.</li>
  <li>The ACPI clock. This is a real clock/timer with a nominal frequency of
      3579545. It is accessed via a 24 or 32 bit register. Unlike the TSC clock,
      it maintains a constant tick rate even when the CPU sleeps or its clock
      rate changes. It is not available to applications.</li>
</ul>
<p class="Pp">Summary: if <code class="Dv">HZ</code> is not 1000000 then the
    application is probably using the wrong clock.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">gprof(1)</a>, <a class="Xr">clock_gettime(2)</a>,
    <a class="Xr">getitimer(2)</a>, <a class="Xr">getrusage(2)</a>,
    <a class="Xr">gettimeofday(2)</a>, <a class="Xr">select(2)</a>,
    <a class="Xr">clock(3)</a>, <a class="Xr">moncontrol(3)</a>,
    <a class="Xr">times(3)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">J&#x00F6;rg
    Wunsch</span> after a description posted by <span class="An">Bruce
    Evans</span>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">January 18, 2008</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>