----- Ursprüngliche Nachricht -----
Von: Sergio Campamá
An: [email protected]
Gesendet am: 19 Aug 2011 17:53:45
Betreff: Re: [Mspgcc-users] RAM Management

>Thanks for the insight into the problem. The thing is that I have a task
>scheduler, a linked list that, well, lists the tasks to perform... Since
>linked lists are dynamic in nature, I need malloc to create the new "task"
>and append it to the list.. And after the task is done, I free the task and
>go on to the next one...  The other place I use linked lists is to maintain
>a list of timers that the application uses to signal certain events... after
>the timer activates, it also gets freed...

>So that is why I need malloc and can't (or don't know how) to do it with
>other types of dynamic storage, or static. (On that subject, what other
>types of dynamic storage exist?)

You can use a semi-dynamic linked list.
When a list element is freed, don't free it, just cut it from the list and
append it to the end with a 'null task' entry.
So when a new task comes up, the already allocated list element
is found after the 'active' ones and can be reused. If the list is full,
you can malloc another element and append it 
(the list grows if necessary), but you never free it again.
The list won't grow larger than required, bu twill not cause heap
congestion.
Also, it might be more performant (depending on your list 
concatenation management, e.g. keep a pointer to the first free 
element, etc.)

JMGross




------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to