From owner-freebsd-hackers Fri Aug 16 19:20:16 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3356737B400 for ; Fri, 16 Aug 2002 19:20:12 -0700 (PDT) Received: from squall.waterspout.com (squall.waterspout.com [208.13.56.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE0D743E6A for ; Fri, 16 Aug 2002 19:20:06 -0700 (PDT) (envelope-from will@csociety.org) Received: by squall.waterspout.com (Postfix, from userid 1050) id 21A669B3A; Fri, 16 Aug 2002 21:20:06 -0500 (EST) Date: Fri, 16 Aug 2002 21:20:06 -0500 From: Will Andrews To: Sean Hamilton Cc: hackers@freebsd.org Subject: Re: microuptime() and nanouptime() library? Message-ID: <20020817022005.GB18228@squall.waterspout.com> References: <000701c24593$ceb71810$8eacb440@slugabed.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000701c24593$ceb71810$8eacb440@slugabed.org> User-Agent: Mutt/1.3.26i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 16, 2002 at 07:14:24PM -0700, Sean Hamilton wrote: > Greetings, > > I just tried to use nanouptime, then microuptime, but was disappointed to > find that a quick grep of /usr/lib revealed no libraries containing these > symbols. > > Are they only available to the kernel. If so, how can I get a reasonable > timer figure from user space? Yes, they are limited to kernel space, as the section they belong to implies: <1 5005-0> (21:16:41) [will@puck ~]% man 9 nanouptime|head -5 MICROUPTIME(9) FreeBSD Kernel Developer's Manual MICROUPTIME(9) NAME microuptime, getmicrouptime, nanouptime, getnanouptime - get the time elapsed since boot gettimeofday() will return a 'struct timeval' which is accurate to the microsecond. There is also a 'struct timespec' defined in sys/time.h but I believe it is restricted to kernel use (and nanotime() with it). [..checking stuff..] Actually.. perhaps not. See clock_gettime(2), but I know nothing about that system call. It does appear to be similar to gettimeofday() semantically and is a POSIX function, so it should also be portable. Regards, -- wca To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message