Hello everyone, I am studying link list in c I have a project in which I have lookup table of rpm (clocks used to load the timer used for motor). This rpm table, I am taking in an array Now I want to implement a link list which will access the rpm from table and load it to timer of clock used for running the motor Is it possible Because as I am studying the link list, in that it is mentioned that link list is used instead of array Is it possible to access an array elements using link list ? If yes, then pls suggest me some link for it Correct me if I am wrong Thank u all
With the '51 architecture, linked lists (dynamically allocated or not) are murder, whereas with e.g. the XA, they can be the best solution. A list like you describe will, I assume be in XDATA, just make a linked list of 3 entries and look at the generated assembler then count the cycles to get to the 3rd entry. Then visualize the time to get to the umpteenth entry.
OK, it may be that you have all the time in the world, so to save the sardine from responding, if you want to totally ignore efficiency, go ahead and link your list.
Erik
"...if you want to totally ignore efficiency, go ahead and link your list."
'scuse me ... But I have used linked lists on an 8052.
You must learn to realise that efficiency is a relative term.
On the project in question, we considered acceptability of execution time at the project start, negotiated requirements with the customer and found, for the requirement that access to the list was considered acceptable when the list contained no more than 750 records.
If it is acceptable to the customer, then the code is sufficiently efficient.
Hint: Try taking off your blinkers - You might see a whole new world!
But did you use them for something that's most likely a static, ordered data structure ?
"But did you use them for something that's most likely a static, ordered data structure ?"
No, the data was dynamic, stored in a fixed area of memory (i.e., no use of malloc or the like), had records of variable length, written relatively infrequently and read relatively more frequently.
The point for us was that, when a search was needed, the required record was found in an acceptable time frame.
No, the data was dynamic,
Well, then you used the right tool for the job.
stored in a fixed area of memory (i.e., no use of malloc or the like),
As far as I've read the docs, the C51 implementations of malloc et al do exactly that - you give them a fixed area of memory and they hand out/free small chunks of it when asked.
Regardless of whether you use malloc or have rolled your own memory allocation functions, you may still run into things like memory fragmentation, though.
"As far as I've read the docs, the C51 implementations of malloc et al do exactly that - you give them a fixed area of memory and they hand out/free small chunks of it when asked."
Sorry, I didn't explain that so clearly. We just used our own simple allocation strategy of the fixed area.
For fragmentation control, we would mark blocks as free and then coalesce the free space at suitable and appropriate times. It was done as a background, interruptable and low priority operation - Again, within acceptable constraints specified by our customer.
Oh dear - There YOU go again! you decide with no such knowledge that effciency does not matter to the OP.
On the project in question, we considered acceptability
If the OP (I was not posting for you) want to ignore efficiency and decide that such is what he wants, what did I say to stop him.
"Oh dear - There YOU go again! you decide with no such knowledge that effciency does not matter to the OP."
And YOU do ???
"With the '51 architecture, linked lists (dynamically allocated or not) are murder"
NO NO NO - Maybe for your one dimensional projects, but for others it can be a real boon.
"On the project in question, we considered acceptability"
It was an attempt to indicate that just because someone gives a response in an apparent authoritative manner, it does not indicate it is the one/only/correct viewpoint.
I just hope the OP is more open minded!
*** Blink, blink - Mr Ego - Blink, blink ***