ntp_gettime(2) system call implementation

Mark Santcroos marks at ripe.net
Wed Nov 17 05:32:13 PST 2004


Background: Since the early days in FreeBSD, ntp_gettime(2) is hacked as 
a libc wrapper around sysctlbyname(3).

I propose to convert it into a system call.

The patch[1] adds the ntp_gettime system call, preserving the sysctl 
behavior for now. However, I want to investigate at some point to get
rid of it in -CURRENT, if we can work out libc compat issues.

The output of my test program[2] is as follows:

   # time ./ntp_gettime-test -ctl 10000000
   13.804u 66.966s 1:24.21 95.9%   5+168k 0+0io 0pf+0w
   # time ./ntp_gettime-test -call 10000000
   4.917u 19.035s 0:24.66 97.0%    5+168k 0+0io 0pf+0w

So the system call is also ~3x as fast as the sysctl version (for
various reasons both in userspace and kernelspace).

As far as the syscall number is concerned, NetBSD and OpenBSD both use 175,
but that is already used in FreeBSD. 
However, in src/sys/compat/svr4/syscalls.master, 248 is used. So I choose to
go for that. I don't feel strongly about that though, so any number would
be fine for me.

Comments welcome, especially about the compat issues later on.

Mark

[1] http://www.santcroos.net/mark/freebsd/files/ntp_gettime.diff
[2] http://www.santcroos.net/mark/freebsd/files/ntp_gettime-test.c

-- 
RIPE NCC - Delft University of Technology - The FreeBSD Project
marks at ripe.net - m.a.santcroos at ewi.tudelft.nl - marks at freebsd.org


More information about the freebsd-arch mailing list