• Welcome to Valhalla Legends Archive.
 

C versus C++

Started by Telos, December 12, 2003, 07:35 AM

Previous topic - Next topic

Adron

Quote from: iago on December 13, 2003, 07:44 AM
Quote
It's easily to atomically link or unlink an element from a singly-linked list without using synchronization primatives.  This is particularly important in kernel mode programmming.
I don't quite undertstand how trees and lists are different here?

To insert an item into a singly linked list, you only need to change one pointer to "commit the transaction". The list never has to be left in an inconsistent state between two instructions.

This means that you don't need to use special synchronization functions to control access to the list when you are adding or removing items. Someone else can safely access the list simultaneously with your modifying it.

This applies to the common operations of inserting object at an end or removing object from an end i.e. to managing a queue, which is very commonly done from more than one thread. A typical example would be requests arriving to some driver or module and getting queued for processing.

iago

Ah, that makes sense, but that hardly ever comes up (in my experience, and probably most people here).  

But the rest of my post stands :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

#17
Quote from: iago on December 13, 2003, 09:13 AM
But the rest of my post stands :)

This strange post stands?!

Quote from: iago on December 13, 2003, 07:44 AM
And I was comparing linked lists to trees, not to arrays.  I'll grant that an array is frequently better than trees or lists, just not that trees are better than lists.

You'll grant that an array frequently is better? I'll grant than an array frequently is worse too! :)

You won't grant that trees are frequently better than lists? I'll say that trees frequently are better than lists, and lists frequently are better than trees.


Quote from: iago on December 13, 2003, 07:44 AM
But the bottom line, that I should have said originally, is that trees are better than ordered linked lists, but necessarely better than arrays

Trees are necessarely better than arrays? I most definitely don't agree. Take for example strings - often stored as arrays of characters. Do you propose that strings now be stored as trees? I doubt you do, and so I think that you should reconsider your post.

edit: Particularly reconsider the contradicting parts...

iago

Sorry, that was a misprint.  I meant not necessarely.  oops :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*