xref: /openbsd-src/share/man/man9/hz.9 (revision a5ac40cbb38d5e7fd01bb3507257d3119f5200d0)
1*a5ac40cbStedu.\"	$OpenBSD: hz.9,v 1.9 2019/01/14 02:05:46 tedu Exp $
28545c142Sespie.\"
38545c142Sespie.\" Copyright (c) 1999 Marc Espie
48545c142Sespie.\" All rights reserved.
58545c142Sespie.\"
68545c142Sespie.\" Redistribution and use in source and binary forms, with or without
78545c142Sespie.\" modification, are permitted provided that the following conditions
88545c142Sespie.\" are met:
98545c142Sespie.\" 1. Redistributions of source code must retain the above copyright
108545c142Sespie.\"    notice, this list of conditions and the following disclaimer.
118545c142Sespie.\" 2. Redistributions in binary form must reproduce the above copyright
128545c142Sespie.\"    notice, this list of conditions and the following disclaimer in the
138545c142Sespie.\"    documentation and/or other materials provided with the distribution.
148545c142Sespie.\"
158545c142Sespie.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168545c142Sespie.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178545c142Sespie.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188545c142Sespie.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198545c142Sespie.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208545c142Sespie.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218545c142Sespie.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228545c142Sespie.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238545c142Sespie.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248545c142Sespie.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258545c142Sespie.\"
26*a5ac40cbStedu.Dd $Mdocdate: January 14 2019 $
278545c142Sespie.Dt HZ 9
288545c142Sespie.Os
298545c142Sespie.Sh NAME
308545c142Sespie.Nm hz ,
318545c142Sespie.Nm tick ,
328545c142Sespie.Nm tickadj ,
338545c142Sespie.Nm stathz ,
348545c142Sespie.Nm profhz
35ca8c6f66Sdavid.Nd system time model
368545c142Sespie.Sh SYNOPSIS
37d41032dcSjmc.Vt extern int hz;
38d41032dcSjmc.Vt extern int tick;
39d41032dcSjmc.Vt extern int tickadj;
40d41032dcSjmc.Vt extern int stathz;
41d41032dcSjmc.Vt extern int profhz;
428545c142Sespie.Sh DESCRIPTION
438545c142SespieThe system is driven by
448545c142Sespie.Xr hardclock 9
458545c142Sespieinterrupts, which occur at
468545c142Sespie.Va hz
478545c142Sespiefrequency, and are used to keep track of real time.
488545c142Sespie.Pp
498545c142SespieOn systems where another independent clock is available, it is set at
508545c142Sespie.Va stathz
51ab967380Saaronfrequency, and used to gather timing statistics.
52ab967380SaaronIdeally, it would be better to drive
532a6b596fStholo.Va stathz
542a6b596fStholowith a slightly randomized clock, that is still a fixed number on average,
55ab967380Saaronas this would prevent malicious processes from working around the scheduler.
56ab967380SaaronIf a separate clock is not available,
578545c142Sespie.Va stathz
588545c142Sespieis set to
598545c142Sespie.Va hz .
608545c142Sespie.Pp
612a6b596fStholoIf profiling is enabled, the clock normally used to drive
622a6b596fStholo.Va stathz
632a6b596fStholomay be run at a higher rate
648545c142Sespie.Va profhz ,
658545c142Sespiewhich must be a multiple of
668545c142Sespie.Va stathz .
672a6b596fStholoThis will give higher resolution profiling information.
688545c142Sespie.Pp
698545c142SespieNormally,
708545c142Sespie.Xr hardclock 9
718545c142Sespieincrements
728545c142Sespie.Va time
738545c142Sespieby
748545c142Sespie.Va tick
758545c142Sespieeach time it is called.
768545c142SespieIf the system clock has drifted,
778545c142Sespie.Xr adjtime 2
788545c142Sespiemay be used to skew this increment, but by no more
798545c142Sespiethan ten times
808545c142Sespie.Va tickadj .
818545c142Sespie.Pp
82*a5ac40cbSteduThese system variables are available by reading
83*a5ac40cbStedu.Dv KERN_CLOCKRATE
84*a5ac40cbStedufrom
85aaeccf36Sderaadt.Xr sysctl 2 .
868545c142Sespie.Sh SEE ALSO
878545c142Sespie.Xr adjtime 2 ,
888545c142Sespie.Xr clock_getres 2 ,
89aaeccf36Sderaadt.Xr sysctl 2 ,
908545c142Sespie.Xr hardclock 9 ,
918545c142Sespie.Xr microtime 9
92