diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2020-06-22 21:16:08 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2020-06-22 21:16:08 +0000 |
commit | e6cb112a7295344bce1bf1f3e7331d85ad0f15c7 (patch) | |
tree | 5118b6fc9af736085ba4a7b992b57b7d9684e9b7 /share | |
parent | 0b079107c7cba84791dceb493c8615f29f3edcd6 (diff) |
timecounting: add gettime(9), getuptime(9)
time_second and time_uptime are used widely in the tree. This is a
problem on 32-bit platforms because time_t is 64-bit, so there is a
potential split-read whenever they are used at or below IPL_CLOCK.
Here are two replacement interfaces: gettime(9) and getuptime(9).
The "get" prefix signifies that they do not read the hardware
timecounter, i.e. they are fast and low-res. The lack of a unit
(e.g. micro, nano) signifies that they yield a plain time_t.
As an optimization on LP64 platforms we can just return time_second or
time_uptime, as a single read is atomic. On 32-bit platforms we need
to do the lockless read loop and get the values from the timecounter.
In a subsequent diff these will be substituted for time_second and
time_uptime almost everywhere in the kernel.
With input from visa@ and dlg@.
ok kettenis@
Diffstat (limited to 'share')
-rw-r--r-- | share/man/man9/microtime.9 | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/share/man/man9/microtime.9 b/share/man/man9/microtime.9 index fc69d8ae607..f8904c6f6a0 100644 --- a/share/man/man9/microtime.9 +++ b/share/man/man9/microtime.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: microtime.9,v 1.20 2020/05/20 17:21:07 cheloha Exp $ +.\" $OpenBSD: microtime.9,v 1.21 2020/06/22 21:16:07 cheloha Exp $ .\" $NetBSD: microtime.9,v 1.2 1999/03/16 00:40:47 garbled Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 20 2020 $ +.Dd $Mdocdate: June 22 2020 $ .Dt MICROTIME 9 .Os .Sh NAME @@ -46,7 +46,9 @@ .Nm bintime , .Nm binuptime , .Nm binruntime , -.Nm binboottime +.Nm binboottime , +.Nm gettime , +.Nm getuptime .Nd system clocks .Sh SYNOPSIS .In sys/time.h @@ -110,6 +112,14 @@ .Fo binboottime .Fa "struct bintime *tv" .Fc +.Ft time_t +.Fo gettime +.Fa "void" +.Fc +.Ft time_t +.Fo getuptime +.Fa "void" +.Fc .Sh DESCRIPTION This family of functions return different system clocks in various formats. The "uptime" functions return the monotonically increasing time since boot. |