This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: memory pools
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: Tom Coremans <tom dot coremans at acunia dot com>
- Cc: eCos users <ecos-discuss at sources dot redhat dot com>
- Date: Mon, 18 Feb 2002 10:07:29 +0100
- Subject: Re: [ECOS] memory pools
- References: <3C70C324.B460AB3@acunia.com>
On Mon, Feb 18, 2002 at 10:02:28AM +0100, Tom Coremans wrote:
>
> Hi ,
>
> To create a memory pool you have to give a pointer to the base of memory
> to use for the pool. What should that be on the linux synthetic
> target??? How can I know where there is a block of memory that I can
> use??
Same way as you do on any target. Declare a static or global array of
bytes and use that. The compiler will put it into the bss and
everything will be happy.
static char sbuf_mem[(NUM_SBUFS+2)*(sizeof(struct sbuf))];
cyg_handle_t sbuf_mem_handle;
static cyg_mempool_fix fix;
cyg_mempool_info info;
void sbuf_init() {
cyg_mempool_fix_create(sbuf_mem,
(NUM_SBUFS+2)*(sizeof(struct sbuf)),
sizeof(struct sbuf),
&sbuf_mem_handle,
&fix);
}
How are you doing it on 'real' targets? Be careful of the heap. Any
spare memory not explicitly allocated to something is eaten up by the
dynamic heap.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss