[ECOS] RE : RE: [ECOS] Problem of sizes for memory pools

Andrew Lunn andrew.lunn@ascom.ch
Mon Jun 30 09:24:00 GMT 2003


On Mon, Jun 30, 2003 at 11:20:28AM +0200, Matthieu.GIRARDIN@fr.thalesgroup.com wrote:
> Ok thank you,
> 
> Your summary is quite good : I don't know at compile time how big the pool
> is. So I
> have to allocate the memory dynamically at run time.
> 
> Now, this is my summary :
> 
> If I have a function (called by an external application) with two parametres
> called nb_blocks and size_block (the size of one block),
> 
> I must do a malloc as follows :
> 	mempoolspace = (void *) malloc ((nb_blocks + X) * size_block)
> 
> (I think it's the equivalent of static char mempoolspace[nb_blocks + X])
> 
> With  the number of extra blocks X defined as 
> 	X = (size / blocksize) - ((size / blocksize / 8 / blocksize) + 1)

I said approximately. Under some conditions i think this
underestimates by 1. Have a look at

packages/services/memalloc/common/current/include/mfiximpl.inl 

> And I can, then, call cyg_mempool_fix_create() with
> 	( mempoolspace, (nb_blocks + X) * size_block, size_block, ... )
> 
> Is it right now ? Are my parametres good ?

Thats correct.

      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



More information about the Ecos-discuss mailing list