I think sharing a pool is one reason why TinyOS advocates against malloc
- overuse in one component can starve another of resources. A separate
pool each guarantees a minimum resource level to everyone. You could
define a union of your data types and have a pool of those, but that
doesn't work very well if the items vary greatly in size. In that case,
you may just want to use malloc(), and make sure you enforce reasonable
limits on each component's use.

Michiel

 

From: Newlyn Erratt [mailto:[email protected]] 
Sent: maandag 30 augustus 2010 17:13
To: Michiel Konstapel
Cc: [email protected]
Subject: Re: RE: [Tinyos-help] Dynamic memory

 

The issue with this was that I was hoping to maintain a single memory
pool for multiple data types. This would allow me to allocate where I
need at run time instead of compile time. I think it would allow me to
have less memory allocated in pools and unusable by user applications
without requiring heavy compile time configuration for users. 

On Aug 30, 2010 11:07 AM, "Michiel Konstapel" <[email protected]>
wrote:
> You can use a Pool and/or Queue. Those (statically) reserve an amount
of
> memory depending on their size, and you can use and reuse that memory
> dynamically at runtime. The typical example is a Pool of message_t
> buffers, which are taken from the Pool, put on the Queue for
forwarding,
> then added back to the pool when they've been sent (see, for example,
> CtpForwardingEngine).
> 
> Michiel
> 
> 
> 
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
Newlyn
> Erratt
> Sent: maandag 30 augustus 2010 15:33
> To: [email protected]
> Subject: [Tinyos-help] Dynamic memory
> 
> 
> 
> All:
> 
> 
> 
> I've been looking through the archives for a few days trying to figure
> out the best solution to this problem. I know that malloc should not
be
> used. I also know that there are some available dynamic memory
> implementations. Notable, I've seen TinyAlloc mentioned (assuming it
> was strictly TinyOS 1.x though) and I've seen the Malloc that is
> provided in the TOSThreads system. My situation is this: I am
> developing a protocol and have several buffer which need varying
amounts
> of memory based on the users configuration. I would like an
> implementation that would allow me to define a memory pool where I may
> allocate memory freely to the buffers. The problem is two-fold. I'm
> not entirely sure if this is the best solution even though it seems
> attractive: does anyone have any other suggestions that aren't too
> limiting? I'm not sure what the best implementation would be for this.
> I've seen it mentioned that there are several options for dynamic
memory
> but I wanted some opinions on what the best solutions are.
> 
> 
> 
> 
> 
> Thanks for any help,
> 
> Newlyn
> 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to