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:07:50PM -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.
> 
> This is going to be close to impossible to achieve. The exact amount of 
> time will depend on:
> 
> * clock speed
> * exact CPU vendor and model (and maybe microcode revision)
> * L1 and L2 cache state
> * alignment of code
> * MMU state
> * (potentially) other hardware tying up buses
> 
> You'll need to examine the instruction timing for your particular specific 
> hardware and write functions of your own methinks.

The classic way of doing delays on x86 is to do a string of
some sort of I/O access cycles (e.g. inw/outw) that took a
relatively long (and fixed) amount of time compared to the loop
overhead. That way you can minimize the effects of cache and
MMU state.

It still requires hand tuning for each platform.

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
platform.

-- 
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]