Different behaviour of RTEMS in QEMU/i386 and SPARC

Till Straumann strauman at slac.stanford.edu
Mon Oct 31 21:04:21 UTC 2011


You may want to try this with a lot of stack space - just
to exclude that it is a stack overflow issue
(since you created the task with minimum stack size)

- T.

On 10/31/2011 02:58 AM, Constantine "chicky" Giotopoulos wrote:
> 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/82f1eeb6/attachment-0001.html>


More information about the users mailing list