Storing an array

Nick.SIMON at syntegra.bt.co.uk Nick.SIMON at syntegra.bt.co.uk
Mon Jun 19 12:54:23 UTC 2000




-- Nick Simon 

> -----Original Message-----
> From: Jorge Andreu Garca [mailto:andreu at robot3.cps.unizar.es]
> Sent: 19 June 2000 12:19
> To: Nick.SIMON at syntegra.bt.co.uk
> Cc: rtems-users at oarcorp.com
> Subject: Re: Storing an array
> 
> 
> Nick.SIMON at syntegra.bt.co.uk wrote:
> 
> > > -----Original Message-----
> > > From: Jorge Andreu Garca [mailto:andreu at robot3.cps.unizar.es]
> > > Sent: 19 June 2000 09:11
> > > To: rtems
> > > Subject: Storing an array
> > >
> > >
> > > Hello:
> > >
> > > I want to use an array of  120.000 integersin a program that
> > > should run
> > > on rtems, but I can't:
> > >
> > > When I store this in memory, the program stop when it read the
> > > declaration line of the array.
> >
> > If your program is executing a declaration it must be an 
> automatic, i.e. on
> > the stack.  I doubt you have 480K bytes of stack space available!
> 
> How much space has the stack more or less? Can I enlarge this size?

You can set the size of your stack, when the task is created.  However, the
stack is best used for small, temporary data items, not big things you want
continuously.

> 
> >
> >
> > > When I store it in heap (with a pointer
> > > in Ada) the computer reboot in the same line.
> >
> > Putting it on the heap is probably the right thing - 
> assuming you have
> > enough space in your heap.
> 
> how can I check if I have enough place?

How much heap are you creating in the first place?  In the BSP I'm using
this is done in bsp_pretasking_hook with a call to bsp_libc_init.

> 
> >
> > If you have (or should have) it could be that your heap has become
> > corrupted.
> >
> > The other valid way to store a large object is as a static 
> or global, if
> > it's something thats needed continuously, or over & over 
> again, in your
> > application.
> 
> Where is stored a global array?

Static data (including globals) go in the .bss or .data segments, depending
on whether it's initialised or not (not -> .bss).  So it's allocated a place
in memory at link time.  For a data structure you need continuously, or
nearly continuously, this is probably the way to go - there's no malloc/free
overhead, and if your program links OK the memory has been allocated OK.

> 
> >
> >
> > >
> > > Is there any function of rtems or any specification file 
> where I can
> > > change the maximum size of the variables?
> >
> > This is done in the BSP. Which are you using?
> 
> I am running my RTEMS program in a Pentium II, so I use the 
> i386-rtems BSP
> 
> >  BTW do you really need 120
> > thousand integers? It does seem a lot.
> 
> The program is used to control an autonomous robot at 
> low-level. I have to
> store all the velocities of both wheel during a second (1 measure per
> milisecond). So I use a 60000 elements vector where each 
> element store the
> velocity of both wheels. So I have 120000 of floats (not 
> integer I realize)
> 

1 measure per mS for 1 second, times 2 wheels, makes 2000 floats, doesn't
it?

> Thanks:
> 
> JORGE
> 
>

Best wishes

-- Nick Simon  




More information about the users mailing list