Hi Andris, Thank you for your answer! You understood correctly and I am aware of the reason why I should not allocate the memory dynamically.
Thus, I will probably set the size of the data at compilation-time. Is there any method how I can find out the available amount of the hardware memory? Thank you very much. Martin -------- Original Message -------- Subject: Re: [Tinyos-help] Managing table with neighbors - dynamic allocation From: András Bíró <bband...@gmail.com> To: Martin Stehlik <stehli...@atlas.cz> Cc: tinyos-help@millennium.berkeley.edu Date: Monday, November 21, 2011 13:39:37 > Hi Martin, > > If I understood correctly, the reason for not recommending dynamic > memory in tinyos is that there's no memory protection at all. Your > data memory grows from one side of the memory, and the stack grows > from the other side, if they're overlap, that could cause a hardly > understandable crash. Using dynamic memory allocation causes > fragmentation in data memory, therefor it's unpredictable when will > they overlap. > So, most peaple sets the size of such data compilation-time, to the > maximum which fits in the hardware memory (warning: the size util, > which prints the rom/ram usage after tinyos compile is not really > accurate, probably because it doesn't count the stack). > > Andris > > On Mon, Nov 21, 2011 at 1:13 PM, Martin Stehlik<stehli...@atlas.cz> wrote: >> Hello! >> >> Is anyone experienced with dynamic allocation of tables (arrays) in >> TinyOS? I need to store a table of neighbors in each of the nodes >> containing some information like RSSI of the messages coming from the >> neighbors etc. I do not know the number of neighbors in advance (I can >> discover them using some "Hello" message etc. whenever). It means that >> the table should grow dynamically once a new neighbor is discovered. >> >> My first idea was using structures and dynamically allocate new items in >> the list (actually an implementation of linked list). Then I read in >> mailing list and in documentation that the usage of malloc etc. is not >> recommended. I have also found several data structures like queue or >> pool but they do not seem to be suitable for my purpose. I could also >> allocate the memory statically during compile time but I am afraid it >> would be wasting of memory and the application would not be robust for >> high amount of neighbors. >> >> Can anyone suggest me some suitable and effective solution for my problem? >> >> I will welcome any answer or suggestion very much! >> >> Best, >> Martin >> _______________________________________________ >> Tinyos-help mailing list >> Tinyos-help@millennium.berkeley.edu >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> _______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help