solaris.html revision 258945
1258945Sroberto<HTML>
2258945Sroberto<HEAD>
3258945Sroberto<TITLE>Solaris hints and kinks</title><link href="scripts/style.css" type="text/css" rel="stylesheet">
4258945Sroberto
5258945Sroberto</HEAD>
6258945Sroberto<BODY>
7258945SrobertoInformation on compiling and executing ntpd under Solaris.
8258945Sroberto<BR>
9258945SrobertoLast Updated: Sun Jun 21 01:32:18 EDT 1998,
10258945SrobertoJohn Hawkinson,
11258945Sroberto<! -- This is deliberately not a mailto -- > &lt;jhawk@MIT.EDU&gt;
12258945Sroberto<P>
13258945SrobertoIf you're not running Solaris 2.5.1 or later, it is likely
14258945Srobertothat you will have problems; upgrading would be a really good plan.
15258945Sroberto<P>
16258945Sroberto<H3>All Solaris versions</H3>
17258945Sroberto<P>
18258945Sroberto      We have a report that says starting with Solaris 2.6 we should leave
19258945Sroberto      <I>dosynctodr</I> alone.
20258945Sroberto      <A HREF="solaris-dosynctodr.html">Here is the report</A>.
21258945Sroberto<P>
22258945SrobertoProper operation of ntp under Solaris may require setting the kernel
23258945Srobertovariable <I>dosynctodr</I> to zero (meaning "do not synchronize the clock
24258945Srobertoto the hardware time-of-day clock").  This can be done with the
25258945Srobertotickadj utility:
26258945Sroberto<BLOCKQUOTE><TT>
27258945Srobertotickadj -s
28258945Sroberto</TT></BLOCKQUOTE>
29258945SrobertoIf you prefer, it can also be done with the native Solaris kernel debugger:
30258945Sroberto<BLOCKQUOTE><TT>
31258945Srobertoecho dosynctodr/W0 | adb -k -w /dev/ksyms /dev/mem
32258945Sroberto</BLOCKQUOTE></TT>
33258945Sroberto<P>
34258945SrobertoOr, it can also be set by adding a line to /etc/system:
35258945Sroberto<BLOCKQUOTE><TT>
36258945Srobertoset dosynctodr = 0
37258945Sroberto</BLOCKQUOTE></TT>
38258945Sroberto<P>
39258945SrobertoInstead of the <I>tick</I> kernel variable, which many operating
40258945Srobertosystems use to control microseconds added to the system time every
41258945Srobertoclock tick (c.f. <A HREF="../notes.html#frequency_tolerance">Dealing
42258945Srobertowith Frequency Tolerance Violations</A>), Solaris has the variables
43258945Sroberto<I>nsec_per_tick</I> and <I>usec_per_tick</I>.
44258945Sroberto<P>
45258945Sroberto<I>nsec_per_tick</I> and <I>usec_per_tick</I> control the number of
46258945Srobertonanoseconds and microseconds, respectively, added to the system clock
47258945Srobertoeach clock interrupt. Enterprising souls may set these based on
48258945Srobertoinformation collected by ntpd in the <CODE>/etc/ntp.drift</CODE> file
49258945Srobertoto correct for individual hardware variations.
50258945Sroberto<P>
51258945SrobertoOn UltraSPARC systems, <I>nsec_per_tick</I> and <I>usec_per_tick</I>
52258945Srobertoare ignored in favor of the <I>cpu_tick_freq</I> variable, which
53258945Srobertoshould be automatically be determined by the PROM in an accurate
54258945Srobertofashion.
55258945Sroberto<P>
56258945SrobertoIn general, the same ntp binaries should not be used across multiple
57258945Srobertooperating system releases. There is enough variation in the core operating
58258945Srobertosystem support for timekeeping that a rebuild of ntpd for the idiosyncracies
59258945Srobertoof your specific operating system version is advisable.
60258945Sroberto<P>
61258945SrobertoIt is recommended that ntp be started via a script like <A
62258945SrobertoHREF="solaris.xtra.S99ntpd">this one</A>, installed in
63258945Sroberto<CODE>/etc/init.d/ntpd</CODE> with a symbol link from
64258945Sroberto<CODE>/etc/rc2.d/S99ntpd</CODE>.
65258945Sroberto
66258945Sroberto<H3>Solaris 2.6</H3>
67258945Sroberto<P>
68258945SrobertoSolaris 2.6 adds support for kernel PLL timekeeping, but breaks this
69258945Srobertosupport in such a fashion that using it worse than not. This is <A
70258945SrobertoHREF="solaris.xtra.4095849"> SUN Bug ID 4095849</A>, and it is not yet
71258945Srobertofixed as of June 1998.
72258945Sroberto<P>
73258945Sroberto<H3>Solaris 2.5 and 2.5.1</H3>
74258945Sroberto<P>
75258945SrobertoOn UltraSPARC systems, calculation of <I>cpu_tick_freq</I> is broken
76258945Srobertosuch that values that are off by significant amounts may be used
77258945Srobertoinstead. This unfortunately means that ntpd may have severe problems
78258945Srobertokeeping synchronization. This is <A HREF="solaris.xtra.4023118"> SUN Bug ID
79258945Sroberto4023118</A>. Bryan Cantrill <! -- &lt;bmc@eng.sun.com&gt; --> of Sun
80258945Srobertoposted <A HREF="solaris.xtra.patchfreq">patchfreq</A>, a workaround script,
81258945Srobertoto comp.protocols.time.ntp in March of 1997.
82258945Sroberto<P>
83258945Sroberto<HR>
84258945Sroberto<H2>OLD DATA</H2>
85258945Sroberto<STRONG>I can't vouch for the accuracy the information below this
86258945Srobertorule. It may be significantly dated or incorrect.</STRONG>
87258945Sroberto<P>
88258945Sroberto<P>
89258945Sroberto<H3>Solaris 2.2</H3>
90258945Sroberto<P>
91258945SrobertoSolaris 2.2 and later contain completely re-written clock code to
92258945Srobertoprovide high resolution microsecond timers. A benefit of the
93258945Srobertore-written clock code is that adjtime does not round off its
94258945Srobertoadjustments, so ntp does not have to compensate for this
95258945Srobertorounding. Under Solaris 2.2 and later, ntp #define's
96258945Sroberto<CODE>ADJTIME_IS_ACCURATE</CODE>, and does not look for the <I>tickadj</I>
97258945Srobertokernel variable.
98258945Sroberto<P>
99258945Sroberto<H3>Solaris 2.1</H3>
100258945Sroberto(This originally written by William L. Jones &lt;jones@chpc.utexas.edu&gt;)
101258945Sroberto<P>
102258945SrobertoSolaris 2.1 contains fairly traditional clock code, with <I>tick</I>
103258945Srobertoand <I>tickadj</I>.
104258945Sroberto<P>
105258945SrobertoSince settimeofday under Solaris 2.1 only sets the seconds part of timeval
106258945Srobertocare must be used in starting xntpd.  I suggest the following start
107258945Srobertoup script:
108258945Sroberto<BLOCKQUOTE><TT>
109258945Srobertotickadj -s -a 1000
110258945Sroberto<BR>ntpdate -v server1 server2
111258945Sroberto<BR>sleep 20
112258945Sroberto<BR>ntpdate -v server1 server2
113258945Sroberto<BR>sleep 20
114258945Sroberto<BR>tickadj -a 200
115258945Sroberto<BR>xntpd
116258945Sroberto</TT></BLOCKQUOTE>
117258945Sroberto
118258945SrobertoThe first tickadj turns of the time of day clock and sets the tick
119258945Srobertoadjust value to 1 millisecond.  This will insure that an adjtime value
120258945Srobertoof at most 2 seconds will complete in 20 seconds.
121258945Sroberto<P>
122258945SrobertoThe first ntpdate will set the time to within two seconds 
123258945Srobertousing settimeofday or it will adjust time using adjtime.
124258945Sroberto<P>
125258945SrobertoThe first sleep insures the adjtime has completed for the first ntpdate.
126258945Sroberto<P>
127258945SrobertoThe second ntpdate will use adjtime to set the time of day since the
128258945Srobertoclock should be within 2 seconds of the correct time.
129258945Sroberto<P>
130258945SrobertoThe second tickadj set the tick adjust system value to 5 microseconds.
131258945Sroberto<P>
132258945SrobertoThe second sleeps insure that adjtime will complete before starting 
133258945Srobertothe next xntpd.
134258945Sroberto<P>
135258945SrobertoI tried running with a tickadj of 5 microseconds with out much success.
136258945Sroberto200 microseconds seems to work well.  
137258945Sroberto<P>
138258945Sroberto<HR>
139258945SrobertoPrior versions of this file had major text contributed by:
140258945Sroberto<MENU>
141258945Sroberto<LI>Denny Gentry &lt;denny@eng.sun.com&gt;
142258945Sroberto</MENU>
143258945Sroberto<BODY>
144258945Sroberto</HTML>
145