#1495 closed defect (fixed)

calling rtems_clock_get_uptime in a tight loop on pc386/QEMU leads to backwards time travel.

Reported by: Gedare Bloom Owned by: Joel Sherrill
Priority: normal Milestone: 4.10
Component: bsps Version: 4.10
Severity: normal Keywords:
Cc: chrisj@… Blocked By:
Blocking:

Description

RTEMS 4.10 -- CVS head

Target: i386, pc386 BSP

Build options: -enable-tests --enable-rtems-debug --disable-posix --enable-maintainer-mode

Problem:
I implemented a load generating loop as part of an RTEMS app, using
the CVS head and pc386 BSP in QEMU. I observed some interesting
behavior when calling uptime in a tight loop. In particular, I get
some backwards time-travel.

Here is a snippet of the code:

rtems_clock_get_uptime(&start_

ts);

while(FOREVER) {

rtems_clock_get_uptime(&stop_ts);
_Timespec_Subtract(&start_ts,&stop_ts,&diff_ts);
if (_Timespec_To_ticks(&diff_ts) >= Tick_Count[argument]) break;

}

here, start_ts, stop_ts, and diff_ts are all struct timespec, and
Tick_Count[argument] is a parametrized integer value. What is
happening is that the loop appears to be ending prematurely.

An example of the values of start_ts, stop_ts, and diff_ts are:
(gdb) p start_ts
$4 = {

tv_sec = 0,
tv_nsec = 200701252

}
(gdb) p stop_ts
$5 = {

tv_sec = 0,
tv_nsec = 200325952

}
(gdb) p diff_ts
$6 = {

tv_sec = -1,
tv_nsec = 999624700

}

I can see that stop_ts < start_ts, and that diff_ts reflects this
negative amount.

Attachments (2)

init.c (1.4 KB) - added by Gedare Bloom on Feb 20, 2010 at 10:23:30 PM.
code that exhibits the bug.
rtems-pc386-ckinit.patch (1.2 KB) - added by Gedare Bloom on Feb 20, 2010 at 10:30:50 PM.
Patch to fix bug.

Download all attachments as: .zip

Change History (5)

Changed on Feb 20, 2010 at 10:23:30 PM by Gedare Bloom

Attachment: init.c added

code that exhibits the bug.

Changed on Feb 20, 2010 at 10:30:50 PM by Gedare Bloom

Attachment: rtems-pc386-ckinit.patch added

Patch to fix bug.

comment:1 Changed on Mar 10, 2010 at 4:16:35 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

comment:2 Changed on Mar 26, 2010 at 1:17:33 AM by Chris Johns

Cc: Chris Johns added

comment:3 Changed on Mar 26, 2010 at 1:55:37 AM by Joel Sherrill

I did not apply this to the 4.9 branch.

The make/custom change was mine and not part of this PR. It was picked up accidentally but I meant to eventually commit it. I no of no current use for NetBoot? format. If needed, there should be a shell script in pc386 to do the conversion. Most loaders use ElF now.

Note: See TracTickets for help on using tickets.