This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Multi-thread crash on ARM7 core


Dear all,

Running a simple multithread application on my platform, my system crashes 
with no evident reason.

I have ported eCos on a component with an ARM7TDMI core.

All the test case runs except some which sometimes crashes (not fails but 
crashes with a bad PC and SP register value, kmutex3 for example).

Before the system crashes, all seems ok, but once it is crashed, the PC and 
SP registers are wrong.

It seems that a thread objet (cyg_thread) is corrupted (stack_ptr which 
points to a code area!) after an interrupt and a context switch.

Have you already met such problems or can you suggest me some trial to be 
able to reach the crash source ?

Thanks in advance for your help,

Joris

The simple application with two threads I use to reproduce this problem is :


<<
#include <cyg/kernel/kapi.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define THREAD_NUMBER 2
#define THREAD_STACK_SIZE 0x2000

cyg_thread thread_s[THREAD_NUMBER];     /* space for two thread objects */

char stack[THREAD_NUMBER][THREAD_STACK_SIZE];   /* space for two 4K stacks */

cyg_handle_t simple_thread[THREAD_NUMBER];

cyg_thread_entry_t simple_program;

cyg_mutex_t cliblock;


/* we install our own startup routine which sets up threads */
void cyg_user_start(void)
{
         unsigned int i ;

         cyg_mutex_init(&cliblock);

         for (i=0;i<THREAD_NUMBER;i++)
         {
                 cyg_thread_create(4, simple_program, (cyg_addrword_t) (i+1),
                         '0'+i, (void *) stack[i], THREAD_STACK_SIZE,
                         &simple_thread[i], &thread_s[i]);
         }

         for (i=0;i<THREAD_NUMBER;i++)
         {
                 cyg_thread_resume(simple_thread[i]);
         }
}

/* this is a simple program which runs in a thread */
void simple_program(cyg_addrword_t data)
{
         int message = (int) data;
         int delay;

         cyg_mutex_lock(&cliblock);

         printf("Beginning execution; thread data is %d\n", message);

*** THE SYSTEM OFTEN CRASH HERE ***

         cyg_mutex_unlock(&cliblock);

         cyg_thread_delay(1);

         for (;;) {
                 delay = 1;

                 cyg_mutex_lock(&cliblock);
                 printf("Thread %d: and now a delay of %d clock ticks\n",
                         message, delay);
                 cyg_mutex_unlock(&cliblock);
                 cyg_thread_delay(delay);
         }
}
 >>





****************************************************************************
Ce message et ses pieces jointes contiennent des informations
confidentielles.
Il est etabli a l'intention exclusive de ses destinataires.
Si vous n'en etes pas destinataire, merci de le detruire et d'en avertir
immediatement l'expediteur.
L'integrite de ce message ne pouvant etre garantie sur Internet, Inventel
Systemes ne peut etre tenue responsable de son contenu.

This e-mail and its attachments are confidential and intended solely for the
addressees.
If you are not the intended recipient of this message, then please delete it
and notify the sender.
Since the integrity of this message cannot be guaranteed on the
Internet,Inventel Systemes cannot therefore be considered responsible for
its content.
****************************************************************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]