Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/26/02 21:08
Read: times


 
#33232 - RE: Erik
"I thought that the only application for it in embedded systems is a serial port buffer."

That would be absolutely the last place to use a linked list!

"When you make a circular buffer you overwrite your data if a big bunch of data came at one time, while with linked list the memory is more flexible to a certain extent."

You're even more likely to miss data with a linked-list buffer while you're messing about handling all the overheads!!

As has already been said, if you've got enough memory to provide a heap big enough to catch all that data, then you've certainly got enough to just make your circular buffer much bigger!
Remember, each block allocated by malloc needs an overhead to maintain the heap & your linked list - you'd be better off putting that straight into a circular buffer!
And how will you know when that big bunch of data is coming? You need to know, so that you can call malloc before it arrives - otherwise you're still going to lose data while you wait for malloc! If you've got enough time to do that, you've got enough time to assert flow control!

Note that linked lists do not have to be dynamically allocated.

An application in embedded systems is in forming a Timer Queue:
You have some Timer structures which are linked into either a "free" or an "active" list. When a "task" wants a timer, it takes the first structure off the "free" list, sets its required values, and adds it to the "active" list.
Your timer "task" goes through the "active" list each "tick", incrementing the timers & checking for expiry. It has some means (eg, flag or call-back) to notify the originating "task" of expiry.
Expired timers are moved back to the "free" list.

Another application is in the implementation of a heap for use by malloc!
Again, you have "free" and "in-use" lists.

List of 19 messages in thread
TopicAuthorDate
linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer, Jez            01/01/70 00:00      
RE: Erik            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: Erik            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
An appropriate example?            01/01/70 00:00      
RE: An appropriate example?            01/01/70 00:00      
RE: An appropriate example?            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: Interrupt precognition            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      
RE: linked list serial port buffer            01/01/70 00:00      

Back to Subject List