Storing an array

Stephan Wilms Stephan.Wilms at CWA.de
Mon Jun 19 13:57:14 UTC 2000


Hi Jorge.

you wrote:
> Nick.SIMON at syntegra.bt.co.uk wrote:
> >
> > 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?

How to do it depends a bit on how you configure your application. If 
you have not done so, please have a thorough look at the chapter 
"Configuring a System" in the "RTEMS C Users Guide". It describes how 
to do the basic application configuration. Essentially there are two 
aproaches:
   1) use the automatic generation mechanism via "confdefs.h"
   2) create all required tables yourself and insert the correct values

Method 1 should be easiest and requires you to specify things like 
stack and heap size via defining macros. If you want to consider method 
2 instead (considerablý more complex) you should best start by looking 
at the chapter "Example Application" in the "C Users Guide".

> > > 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?

Hmmm, Ada ? Sorry, but I do not know anything about Ada. There should 
be an "RTEMS Ada Users Guide" though. Have a look at the OAR FTP site 
(accessible through the web site). Hopefully it will provide some 
helpful information.

For a C application all relevant RTEMS startup configuration 
information (and this includes basic memory setup) has to be entered 
into data structures that the RTEMS executive uses for initialisation. 
The Users Guide explains this and tells you how to easily customize 
this to your own needs. The tables configure how much memory RTEMS 
claims for itself, ie. for internal purposes. Typical BSP behaviour is 
to use the rest of the available physical memory as heap memory. Things 
that get subtracted from RAM are for instance:
  - the code (if it resides in RAM)
  - the data segment
  - the internal RTEMS memory (also called RTEMS Workspace)

There is a more general high level aspect of heap memory here, though, 
that I am missing in your description. In C heap memory (also called 
dynamic memory) is available through the "malloc()" function, which 
actually tells you whether the allocation request succeeds (a NULL 
pointer is returned). So your program knows whether it gets the memory 
it needs.

> > 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?

In the data segment of your application. Storage and management of code 
and global data memory is a basic aspect of the BSP and is usually 
handled at the linkage stage of building an application.

> > 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

Do take the time to look at the RTEMS documentation. In addition to the 
"Users Guide" you will find an "i386 Application Supplement" and a 
"Developement Environment Guide".

Greetings,

--
Stephan Wilms (stephan.wilms at cwa.de) 
CWA-GmbH, Aachen, Germany



More information about the users mailing list