[Openec] 8051 reentrancy

Frieder Ferlemann frieder.ferlemann at web.de
Thu Jul 31 16:54:31 EDT 2008


Hi,

pgf at laptop.org schrieb:
> [ beware -- list-crosspost ]
> 
> it seems that at least some of the instability that i've been
> seeing is that the interrupt routines (and/or some of the
> routines they call) weren't reentrant, when i thought they would

Could the cause of this "instability" be related to stack overflow?

Does a "stack cookie" remain untouched? you could check like this:



-------8<-------------------------------------------
#define STACK_COOKIE (0xabcd)

static volatile unsigned int irq_count;

void init_this(){}
void init_that(){}

bit do_this(){ return 1; }
bit do_that(){ return 0; }


bit all_up_and_well()
{
     return STACK_COOKIE == *(unsigned int __idata *)0x7e;
}


void core_dump(){}


void irq_routine1(void) __interrupt (1)
{
     irq_count++;
     irq_count %= 1024;
}


void main(void)
{
     *(unsigned int __idata *)0x7e = STACK_COOKIE; // place cookie near or at top of stack

     init_this();
     init_that();

     while(1)
     {
         do_this();
         do_that();

         if( !all_up_and_well() )
             core_dump();
     }
}
------->8-------------------------------------------

Which kind of "instability" do you observe?


Greetings,
Frieder



More information about the Openec mailing list