From owner-freebsd-hackers Tue Mar 4 15: 2:17 2003 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 6527237B405 for ; Tue, 4 Mar 2003 15:02:15 -0800 (PST) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF3C743F75 for ; Tue, 4 Mar 2003 15:02:13 -0800 (PST) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h24N28A7023515; Tue, 4 Mar 2003 16:02:09 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 04 Mar 2003 15:41:13 -0700 (MST) Message-Id: <20030304.154113.90196009.imp@bsdimp.com> To: jan@digitaldaemon.com Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: 'ticks' in kernel. From: "M. Warner Losh" In-Reply-To: <3E64F7B2.9040008@digitaldaemon.com> References: <3E64E941.3030205@digitaldaemon.com> <20030304.104403.34570707.imp@bsdimp.com> <3E64F7B2.9040008@digitaldaemon.com> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 In message: <3E64F7B2.9040008@digitaldaemon.com> Jan Knepper writes: : How would they return me the 'value' of 'ticks'? : : The problem is... I have a value's somewhere that has been assigned from : 'ticks', like: : ptr -> value = ticks; : : at an other moment I need to do something like... : : age = boottime + ( ticks - ptr -> value ) / factor; : : The problem in the second case however is that I can not seem to get to : 'ticks' as it is userland code... ptr->value should be set with getmicrotime() or microtime(). You can then do a gettimeofday in userland to figure out the age. MICROTIME(9) FreeBSD Kernel Developer's Manual MICROTIME(9) NAME microtime, getmicrotime, nanotime, getnanotime - get the current time SYNOPSIS #include void microtime(struct timeval *tv); void getmicrotime(struct timeval *tv); void nanotime(struct timespec *ts); void getnanotime(struct timespec *tsp); DESCRIPTION The microtime() and getmicrotime() functions store the system time as a struct timeval at the address specified by tv. The nanotime() and getnanotime() functions perform the same utility, but record the time as a struct timespec instead. Microtime() and nanotime() always query the timecounter to return the current time as precisely as possible. Whereas getmicrotime() and getnanotime() functions are abstractions which return a less precise, but faster to obtain, time. The intent of the getmicrotime() and getnanotime() functions is to enforce the user's preference for timer accuracy versus execution time. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message