This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RE : RE: Problem of sizes for memory pools


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]