Date: Tue, 01 May 2001 11:35:39 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Terry Lambert <tlambert@primenet.com> Cc: freebsd-alpha@FreeBSD.org, (Rolf Neugebauer) <neugebar@dcs.gla.ac.uk> Subject: Re: determine cycle counter frequency in user space Message-ID: <XFMail.010501113539.jhb@FreeBSD.org> In-Reply-To: <200105011758.KAA17133@usr01.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 01-May-01 Terry Lambert wrote: > Minimally, you will require periodic resynchornization with > the kernel drift information stored in timer structure. You > should see /sys/i386/isa/clock.c and the timer code in the > file /sys/kern/kern_time.c. You have _got_ to be kidding me Terry. This is freebsd-_alpha_@FreeBSD.org. /sys/i386/anything isn't very relevant here. :) /sys/alpha would be a better place to investigate. Using microtime or microuptime in the kernel in a critical section (or at splhigh for 4.x I would guess) in conjuction with each rpcc would be perfectly sufficient: struct timeval *start_tv, end_tv; register_t start_cc, end_cc; critical_t s; s = critical_enter(); microuptime(&start_tv); start_cc = alpha_rpcc(); critical_exit(s); tsleep(&foo, PUSER, "ccsec", 10); s = critical_enter(); microuptime(&end_tv); end_cc = alpha_rpcc(); critical_exit(s); /* do calculations here */ 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: mtx_lock_spin(&sclock_lock); microuptime(&start_tv); start_cc = alpha_rpcc(); for (count = 0; count < 1000000000; count ++) ; /* nothing */ microuptime(&end_tv); end_cc = alpha_rpcc(); mtx_unlock_spin(&clock_lock); /* do calculations here */ (In -current of course, in -stable splhigh() instead of the mutex ops would probably work as well.) This isn't cheap though. :) -- 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.010501113539.jhb>