Date: Wed, 21 Feb 2018 15:14:27 -0700 From: Warner Losh <imp@bsdimp.com> To: Alan Somers <asomers@freebsd.org> Cc: freebsd-standards@freebsd.org Subject: Re: Using the monotonic clock in time(1)? Message-ID: <CANCZdfpLkoLQi5epaUnEP2=PVEwS-EEV_B=%2B6i3oo9-WYT6tvQ@mail.gmail.com> In-Reply-To: <CAOtMX2jjeVRxuKPdM4hhrbz8NG%2B_kx_Q2jS-QZs52BbB%2BYOt=Q@mail.gmail.com> References: <CAOtMX2jjeVRxuKPdM4hhrbz8NG%2B_kx_Q2jS-QZs52BbB%2BYOt=Q@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 21, 2018 at 2:33 PM, Alan Somers <asomers@freebsd.org> wrote: > time(1) currently uses the realtime clock, which is undesirable for timing > short-lived commands while ntpd is active. I opened a review to add an > option to use the monotonic clock instead, but jilles suggested that time > should use the monotonic clock unconditionally, since that's almost always > better for measuring short durations. However, the Open Group's > specification seems to require the real time clock. What do the standards > folks think? Is the Open Group spec sufficiently ambiguous and/or wrong > that we should switch to the monotonic clock instead? > > https://reviews.freebsd.org/D14032 > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/time.html The issue with ntpd should only be the initial step. After that it steers the frequency of the base clock which affects all clocks. It should be a rare issue that the two clocks give different results. Having said that I see no issue with using a monotonic clock here. I think there's enough wiggle room in the standard to support it. It's really the only clock you can t2-t1 with and get a guaranteed to be meaningful answer. I can't imagine the OpenGroup specifies what happens over a time step the real time clock for programs timed with time. The (real) is in parens, which is not a normative form for specifying the time. I'm not a professional standards lawyer, but my amateur reading says this is a good change. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpLkoLQi5epaUnEP2=PVEwS-EEV_B=%2B6i3oo9-WYT6tvQ>