Timer resolution et al : Implementation of Read_timer()

sashti srinivasan svasn_rtems at yahoo.com
Thu Mar 11 08:20:52 UTC 2004

    The idea is to measure with an accuracy of 1
microsecond without changing lowering
facilities provided by 8254 are sufficient for this
purpose.  In the function Read_timer() on non-pentium,
pc386, the computation is like this:
  total  = (Ttimer_val * US_PER_ISR) + (US_PER_ISR -

   It is convincing that the variable 'clicks' gives
the snapshot of counter0 in 8254.  But, the macro
US_PER_ISR is hardcoded to 250.  Should it not be same
as BSP_Configuration.microseconds_per_tick?

    Assuming that 'Ttimer_val' counts each tick after
timer initialization(Probably this is what expected)
should not the above expression be like the one
  total  = (Ttimer_val *
BSP_Configuration.microseconds_per_tick) +   

    I intend doing the following for measuring with
microsecond accuracy on pc386 keeping 10 millisecond
clock tick.  Please suggest me whether it is OK.
  (1)  Measure time intervals to the accuracy of 10ms
using functions like gettimeofday().
  (2)  With this add difference in value of
TICK_TO_US(clicks) between the points of measurement
to get an accuracy of 1 microsecond.

> Brian is correct.  a 10 microsecond clock tick is
> going to end up with you
> spending nearly all the CPU time serving tick
> interrupts.  Having a 2nd 
> source
> for benchmark purposes is the ideal solution.
> The current pc386 timer is setup to use the TSC
> register for p5 and above.
> On 486 and below it uses the same timer hardware as
> the clock tick driver.
> If you can change it so on 486 and below it uses
> different hardware,

     8254 offers facility to read the current value of
counter at any time.  In the clock driver, the global
   rtems_unsigned32 Clock_driver_ticks
  is used for counting each clock tick.  This and the
current snapshot of counter0 can together be used to
measure with 1 microsecond accuracy.  Will it be
correct to do so?

With Regards

Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster

More information about the users mailing list