From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVav4-0001R5-GD for qemu-devel@nongnu.org; Sun, 25 Mar 2007 18:10:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVav3-0001Ql-2s for qemu-devel@nongnu.org; Sun, 25 Mar 2007 18:10:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVav2-0001Qi-TO for qemu-devel@nongnu.org; Sun, 25 Mar 2007 17:10:32 -0500 Received: from ug-out-1314.google.com ([66.249.92.168]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HVasr-00014q-Ha for qemu-devel@nongnu.org; Sun, 25 Mar 2007 18:08:17 -0400 Received: by ug-out-1314.google.com with SMTP id j40so1632053ugd for ; Sun, 25 Mar 2007 15:08:16 -0700 (PDT) Message-ID: Date: Mon, 26 Mar 2007 00:08:15 +0200 From: "andrzej zaborowski" Sender: balrogg@gmail.com Subject: Re: [Qemu-devel] Patch: cpu-all.h for better cycle counter In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070321023726.GA11696@fries.net> Reply-To: balrogg@gmail.com, qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: todd@fries.net, qemu-devel@nongnu.org On 26/03/07, andrzej zaborowski wrote: > Hi, > > On 21/03/07, Todd T. Fries wrote: > > This is relative to the 20070319 snapshot. > > > > --- cpu-all.h.orig Fri Mar 16 18:58:11 2007 > > +++ cpu-all.h Tue Mar 20 21:14:10 2007 > > @@ -1012,13 +1012,22 @@ static inline int64_t cpu_get_real_ticks > > #endif > > } > > #else > > -/* The host CPU doesn't have an easily accessible cycle counter. > > - Just return a monotonically increasing vlue. This will be totally wrong, > > - but hopefully better than nothing. */ > > +# warning non-optimized CPU > > +#include > > +#include > > + > > static inline int64_t cpu_get_real_ticks (void) > > { > > - static int64_t ticks = 0; > > - return ticks++; > > + struct timeval tv; > > + static int64_t i = 0; > > + int64_t j; > > + > > + gettimeofday(&tv, NULL); > > + do { > > + j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec; > > + } while (i == j); > > + i = j; > > + return j; > > Isn't this an infinite loop? gettimeofday() was left out of the loop. > > How about "return j + (ticks++)" instead of the loop? If I understand > correctly it may slow things down to below 1Hz. (I wanted to say MHz) > > > } > > #endif > > > > -- > > Todd Fries .. todd@fries.net > > > > _____________________________________________ > > | \ 1.636.410.0632 (voice) > > | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) > > | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) > > | "..in support of free software solutions." \ 250797 (FWD) > > | \ > > \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ > > > > 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A > > http://todd.fries.net/pgp.txt > > > > > > > > > > Regards, > Andrew >