1.\" $NetBSD: hz.9,v 1.9 2010/03/26 19:40:41 wiz Exp $ 2.\" 3.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Thomas Klausner. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd March 25, 2010 31.Dt HZ 9 32.Os 33.Sh NAME 34.Nm hz , 35.Nm tick , 36.Nm tickadj , 37.Nm stathz , 38.Nm profhz 39.Nd system time model 40.Sh SYNOPSIS 41.In sys/kernel.h 42.Pp 43.Vt extern int hz; 44.Vt extern int tick; 45.Vt extern int tickadj; 46.Vt extern int stathz; 47.Vt extern int profhz; 48.\" XXX: .Vt extern int schedhz; ? 49.Sh DESCRIPTION 50The essential clock handling routines in 51.Nx 52are written to operate with two timers that run independently of each other. 53The main clock, running 54.Va hz 55times per second, is used to keep track of real time. 56.Pp 57In another words, 58.Va hz 59specifies the number of times the 60.Xr hardclock 9 61timer ticks per second. 62Normally 63.Xr hardclock 9 64increments time by 65.Va tick 66each time it is called. 67If the system clock has drifted, 68.Xr adjtime 2 69may be used to skew this increment based on the rate of 70.Va tickadj . 71.Pp 72The second timer is used to gather timing statistics. 73It also handles kernel and user profiling. 74If the second timer is programmable, 75it is randomized to avoid aliasing between the two clocks. 76The mean frequency of the second timer is 77.Va stathz . 78If a separate clock is not available, 79.Va stathz 80is set to 81.Va hz . 82.Pp 83If profiling is enabled, the clock normally used to drive 84.Va stathz 85may be run at a higher rate 86.Va profhz , 87which is required to be a multiple of 88.Va stathz . 89This will give higher resolution profiling information. 90.Pp 91These system variables are also available as 92.Em struct clockinfo 93from 94.Xr sysctl 3 95and 96.Sy kern.clockrate 97from 98.Xr sysctl 8 . 99The 100.Va hz 101is hardware-dependent; it can be overridden 102(if the machine dependent code supports this) by defining 103.Dv HZ 104in the kernel configuration file (see 105.Xr options 4 ) . 106Only override the default value if you really know what you are doing. 107.Sh SEE ALSO 108.Xr adjtime 2 , 109.Xr callout 9 , 110.Xr hardclock 9 , 111.Xr microtime 9 , 112.Xr time_second 9 113