This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Functions to consume CPU time in x86


On Wed, Mar 28, 2001 at 03:30:33PM -0500, Lewin A.R.W. Edwards wrote:

> > > >And of course I want to be able to specify that I want to keep
> > > >the CPU busy for specific X (mili/nano)seconds and not only
> > > >keep it busy for some randon amount of time.
> >
> >Unless you've got access to a hardware counter (with a known
> >clock rate), you're going to have to tune a delay loop for your
> 
> Oh, one silly thing I forgot - On Pentium and higher x86 CPUs,
> you have the TSC MSR which is incremented every CPU clock
> cycle. You can use this to measure elapsed time. For very small
> values this will obviously not be an accurate technique for
> yielding delays, though.

The problem with fancy processors these days (w/ cache, MMU) is
that the call/return overhead is not fixed the way it was in
the "good old days".  If it is, then you can calibrate it out
by shortening the delay routines "internal" delay by the same
amount as the call/return overhead.

-- 
Grant Edwards
grante@visi.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]