public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Unable to create thread with stack on the PowerPC Simulator
@ 2010-01-10 15:45 Vimala Bauer
  2010-01-10 22:36 ` [ECOS] " John Dallaway
  0 siblings, 1 reply; 2+ messages in thread
From: Vimala Bauer @ 2010-01-10 15:45 UTC (permalink / raw)
  To: ecos-discuss

Hello!

I have tried to run a C program, which creates 4 threads each with stack 
size 100000 bytes,
on the PowerPC simulator (the program listing is given below).
I get the following error message:

"ERROR; return code from pthread_create() is 11"

When I use a stack size of 5000 bytes, it works. It looks like there is 
not enough memory
available. How do I fix it? Does this have something to do with the 
following macro included
in the .gdbinit file?

define psim   
 target sim -o '/iobus/pal@0xf0001000/reg 0xf0001000 32'   
 rbreak cyg_test_exit   
 rbreak cyg_assert_fail  
end


Do I have to make modifications here?


Thank you very much in advance.

Kind regards, Vimala Bauer

PS

Here is the C program:

#include <pthread.h>
#include <stdio.h>
#define NTHREADS 4
#define N 1000
#define MEGEXTRA 1000000
 
pthread_attr_t attr;
 
void *dowork(void *threadid)
{
   double A[N][N];
   int i,j;
   long tid;
   size_t mystacksize;

   tid = (long)threadid;
   pthread_attr_getstacksize (&attr, &mystacksize);
   printf("Thread %ld: stack size = %li bytes \n", tid, mystacksize);
   for (i=0; i<N; i++)
     for (j=0; j<N; j++)
      A[i][j] = ((i*j)/3.452) + (N-i);
   pthread_exit(NULL);
}
 
int main(int argc, char *argv[])
{
   pthread_t threads[NTHREADS];
   size_t stacksize;
   int rc;
   long t;
 
   pthread_attr_init(&attr);
   pthread_attr_getstacksize (&attr, &stacksize);
   printf("Default stack size = %li\n", stacksize);
   stacksize = sizeof(double)*N*N+MEGEXTRA;
   printf("Amount of stack needed per thread = %li\n",stacksize);
   pthread_attr_setstacksize (&attr, stacksize);
   printf("Creating threads with stack size = %li bytes\n",stacksize);
   for(t=0; t<NTHREADS; t++){
      rc = pthread_create(&threads[t], &attr, dowork, (void *)t);
      if (rc){
         printf("ERROR; return code from pthread_create() is %d\n", rc);
         exit(-1);
      }
   }
   printf("Created %ld threads.\n", t);
   pthread_exit(NULL);
}



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ECOS] Re: Unable to create thread with stack on the PowerPC Simulator
  2010-01-10 15:45 [ECOS] Unable to create thread with stack on the PowerPC Simulator Vimala Bauer
@ 2010-01-10 22:36 ` John Dallaway
  0 siblings, 0 replies; 2+ messages in thread
From: John Dallaway @ 2010-01-10 22:36 UTC (permalink / raw)
  To: Vimala Bauer; +Cc: eCos Discussion

Hi Vimala

Vimala Bauer wrote:

> I have tried to run a C program, which creates 4 threads each with stack
> size 100000 bytes,
> on the PowerPC simulator (the program listing is given below).
> I get the following error message:
> 
> "ERROR; return code from pthread_create() is 11"
> 
> When I use a stack size of 5000 bytes, it works. It looks like there is
> not enough memory
> available. How do I fix it? Does this have something to do with the
> following macro included
> in the .gdbinit file?
> 
> define psim   target sim -o '/iobus/pal&commat;0xf0001000/reg 0xf0001000
> 32'   rbreak cyg_test_exit   rbreak cyg_assert_fail  end
> 
> Do I have to make modifications here?

The typical GDB command for using PSIM with eCos is as follows:

> target sim -o '/#address-cells 1' -o '/openprom/init/register/pc 0x100' -o '/iobus@0xf0000000/reg 0xf0000000 0x01000000' -o '/iobus/pal@0xf0001000/reg 0xf0001000 32'

The eCos memory layout for PSIM assumes 1MB RAM.

I hope this helps...

John Dallaway
eCos maintainer

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-10 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-10 15:45 [ECOS] Unable to create thread with stack on the PowerPC Simulator Vimala Bauer
2010-01-10 22:36 ` [ECOS] " John Dallaway

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).