Date: Tue, 01 May 2001 13:02:57 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Terry Lambert <tlambert@primenet.com> Cc: ((Rolf Neugebauer)) <neugebar@dcs.gla.ac.uk>, freebsd-alpha@FreeBSD.org Subject: Re: determine cycle counter frequency in user space Message-ID: <XFMail.010501130257.jhb@FreeBSD.org> In-Reply-To: <200105011908.MAA05338@usr06.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 01-May-01 Terry Lambert wrote: >> There is still the problem on an SMP system that you may spin on >> a lock in microuptime() while talking to the i8254. Also, I >> probably fubb'd the priority to tsleep(), and some different >> timeouts might be more optimal. To be truly pedantic, one could >> make the clock lock allow recursion and do something along >> these lines: > > ... probably overkill; IMO, you only really care about whichever > processor you are running on. Too bad you can't synchornize the > cycle counters on any hardware I'm aware of to date. 8-(. It's not which processor I'm on that I care about. I want to minimize the error that would arise if the time between the micruptime() and alpha_rpcc() at the start is different from that between microuptime() and alpha_rpcc() at the end. Spinning on a lock or getting an interrupt in that time would increase the error. >> (In -current of course, in -stable splhigh() instead of the mutex ops would >> probably work as well.) >> >> This isn't cheap though. :) > > I think he probably wants what I wanted: a "gettimeofday()" that > is "close enough for 1ms or better logging" and doesn't require > call overhead. > > It's unfortunate that there's no "curtime" that could be abused > to provide this... getmicrotime(). It just reads the current time without dinking with the hardware. However, the original poster wanted the alpha-specific cycles_per_sec variable exported as a sysctl, not a new gettimeofday() call. If gettimeofday() really gets your panties in a bunch, you could change it to use getmicrotime() instead of microtime() at the risk of it becoming less accurate. -- John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.010501130257.jhb>