qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "andrzej zaborowski" <balrog@zabor.org>
To: todd@fries.net, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Patch: cpu-all.h for better cycle counter
Date: Mon, 26 Mar 2007 00:08:15 +0200	[thread overview]
Message-ID: <fb249edb0703251508m6b96c47v646a0e2c9ade7629@mail.gmail.com> (raw)
In-Reply-To: <fb249edb0703251507q6085d6dfi13340ecf15693f78@mail.gmail.com>

On 26/03/07, andrzej zaborowski <balrog@zabor.org> wrote:
> Hi,
>
> On 21/03/07, Todd T. Fries <todd@fries.net> 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 <sys/time.h>
> > +#include <time.h>
> > +
> >  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
>

  reply	other threads:[~2007-03-25 22:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-21  2:37 [Qemu-devel] Patch: cpu-all.h for better cycle counter Todd T. Fries
2007-03-25 22:07 ` andrzej zaborowski
2007-03-25 22:08   ` andrzej zaborowski [this message]
2007-03-26 12:52     ` Marc Lörner
2007-03-26 20:37       ` andrzej zaborowski
2007-03-27  6:33         ` Marc Lörner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb249edb0703251508m6b96c47v646a0e2c9ade7629@mail.gmail.com \
    --to=balrog@zabor.org \
    --cc=balrogg@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=todd@fries.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).