Different behaviour of RTEMS in QEMU/i386 and SPARC

Constantine "chicky" Giotopoulos kotsosgiotopoulos at gmail.com
Mon Oct 31 08:58:57 UTC 2011


Hello everyone.

Using RTEMS 4.8.2, I create a single task that executes the code of
"paranoia.c" (it is included when installing RTEMS 4.8.2 in the path
.../rtems-4.8.2/testsuites/samples/paranoia/paranoia.c):


rtems_task Init( rtems_task_argument ignored )

{

rtems_status_code status; rtems_id id;

//Create and start the first task

status = rtems_task_create( rtems_build_name( 'T', 'A', '1', ' ' ), 1,
RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES |
RTEMS_FLOATING_POINT, &id);

assert( !status );

status = rtems_task_start( id, task1, 0 );

assert( !status );

status = rtems_task_delete( RTEMS_SELF );

exit( 0 );

}

rtems_task task1( rtems_task_argument ignored )

{

paranoia();

rtems_task_delete(RTEMS_SELF);

}



Paranoia program contains a number of functions that perform floating point
operations.

When I execute the aforementioned code on a SPARC machine it works
perfectly. But when I execute the same code using Qemu/i386 the execution
halts when "Milestone 140" is reached, and more specifically after the line
indicated bellow:

/*=============================================*/

Milestone = 140;

/*=============================================*/

printf ("\n");

/* ...calculate Exp2 == exp(2) == 7.389056099... */

X = Zero;

I = 2;

Y = Two * Three;

Q = Zero;

N = 0;

do {

   Z = X;

   I = I + 1;

   Y = Y / (I + I);

   R = Y + Q;

   X = Z + R;

   Q = (Z - X) + R;

}

while (X > Z);

Z = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo);

X = Z * Z;

Exp2 = X * X;

X = F9;

Y = X - U1;

*printf ("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n",
Exp2);*

for (I = 1;;) {

   Z = X - BInvrse;

   Z = (X + One) / (Z - (One - BInvrse));

  Q = POW (X, Z) - Exp2;

   if (FABS (Q) > TwoForty * U2) {

       N = 1;

       V9 = (X - BInvrse) - (One - BInvrse);

       BadCond (Defect, "Calculated");

       printf (" %.17e for\n", POW (X, Z));

       printf ("\t(1 + (%.17e) ^ (%.17e);\n", V9, Z);

       printf ("\tdiffers from correct value by %.17e .\n", Q);

       printf ("\tThis much error may spoil financial\n");

       printf ("\tcalculations involving tiny interest rates.\n");

       break;

   }

   else {

       Z = (Y - X) * Two + Y;

       X = Y;

       Y = Z;

       Z = One + (X - F9) * (X - F9);

            if (Z > One && I < NoTrials)

                  I++;

            else {

                  if (X > One)

                  {

                        if (N == 0)

                               printf ("Accuracy seems adequate.\n");

                        break;

                  }

                  else

                  {

                       X = One + U2;

                       Y = U2 + U2;

                       Y += X;

                        I = 1;

                  }

           }

     }

}

/*=============================================*/

Milestone = 150;

/*=============================================*/

.................



In other words, the program executes until the

*printf ("Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\n",
Exp2);*

but stops there. If I comment out the section of the code, the rest of the
program executes normally.

What could be the case for this behaviour? Why is the code running smootly
on a SPARC but not on Qemu/i386 and how could I work out an explaination?



Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20111031/4b3de43f/attachment.html>


More information about the users mailing list