[ECOS] A beginner is playing with memory pools

Jonathan Larmour jifl@eCosCentric.com
Wed Jun 25 18:31:00 GMT 2003


Matthieu.GIRARDIN@fr.thalesgroup.com wrote:
> Hello everybody,
> 
> Sorry to disturb you. I can imagine you're busy as I am but I've a lack of
> knowledge about memory pool.
> So if someone would answer my questions, it would be great. Thanks by
> advance.
> 
> I want to use cyg_mempool_fix_create().
> Do I need to allocate a memory zone with a malloc BEFORE to use this
> function ?

Yes you need to already have the space to use preallocated and pass it in. 
But tt seems wasteful to use malloc for this though! Just static char 
mempool[100*1024]; or something will do.

> If I must do it, I think the parametre called "base" might be the address of
> this zone, no ?
> And if I must allocate BEFORE, what the existing reason of the parametre
> size ?

So it knows how big that area that's been allocated is of course!

> Another thing, what's the last parametre ? I didn't understand because we
> use a cyg-handle_t in the other associated functions (cyg_mempool_fix_alloc
> ...)

It's the space for the memory pool metadata. For example, do something like:

static cyg_mempool_fix mymempool;
static char mempoolspace[100*1024];
static cyg_handle_t h;

cyg_mempool_fix_create( mempoolspace, sizeof(mempoolspace), 64, &h, 
&mymempool);

> I'm sorry but I've not enough documentation to understand all this ecos
> object ...

Yes it accidently wasn't included in a documentation rewrite. This may 
help: http://ecos.sourceware.org/ecos/docs-1.3.1/ref/ecos-ref.9.html#36601

Jifl
-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


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



More information about the Ecos-discuss mailing list