[RTEMS Project] #2230: PowerPC with mpc6xx clock: Nanoseconds extension doesn't compensate for pending clock tick, time may go backwards

RTEMS trac trac at rtems.org
Tue Jan 20 06:29:45 UTC 2015


#2230: PowerPC with mpc6xx clock: Nanoseconds extension doesn't compensate for
pending clock tick, time may go backwards
-------------------------------------------------+-------------------------
 Reporter:  nick.withers                         |       Owner:
     Type:  defect                               |      Status:  new
 Priority:  normal                               |   Milestone:  4.11
Component:  bsps                                 |     Version:  4.11
 Severity:  normal                               |  Resolution:
 Keywords:  clock, time, backwards, race,        |
  nanoseconds, monotonic                         |
-------------------------------------------------+-------------------------

Comment (by sebastian.huber):

 I would drop the multiplication by 1000 and use something like this:

 static uint32_t lpc_clock_nanoseconds_since_last_tick(void)
 {
   uint64_t k = (1000000000ULL << 32) / time_base_frequency;
   uint64_t c = ticks_since_last_exception();

   if ((TSR & DIS) != 0) {
     c = ticks_since_last_exception() + period;
   }

   return (uint32_t) ((c * k) >> 32);
 }

 I would also do the Book E check only once and install different
 extensions instead. If you use the network stack, then this function is
 performance critical.

--
Ticket URL: <http://devel.rtems.org/ticket/2230#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list