On Mon, Mar 15, 2004 at 10:37:21 +0300, Ruslan U. Zakirov wrote: > Zeeshan Ali wrote: > >Hello, > > > > > >>The linked list implementation is generic, and it is > >>not kernel-oriented as you claimed. > > It is generic (can be used for any list) and not kernel-oriented (you can include linux/list.h to user-space application and use it). > > > > It certainly is, as it requires the list_head to > >be the part of the data. Please correct me if i am > >wrong. Yes, it requires so. But of course, you are free to build external list on top of it: struct ext_list { list_head list; void * data; }; > You are wrong because I think that it's benefit of kernel indirect(with > magic) lists, it saves memory. I don't know place where it's better to > use direct pointer in list element. Do you know? > > Why it's benefit? Because if you want list of 'XObj' then often(allways) > have more(or equal) list elements then 'XObj' instances altogether.So > memory usage for current kernel lists: > sizeof(pointer)*(2*"NumberOfListElements"+"NumberOfXObj") > > in case of GList: > sizeof(pointer)*(3*"NumberOfListElements") > > I think that at least one time you have to put any 'XObj' instance in > some list so we got equality of memory usage, but if we want more > ocurances of instance then GList loose on memory. Internal linked lists (with next/prev as part of data) only allows the structure to be part of one list. Of course, you can have more than one list_head included, but they can't be used interchangeably. In kernel, it turns out that most object are on exactly one list of a kind. Eg. dentry is in a hash (global) and in children list of exactly one parent. For this, internal lists use less memory and are a little bit faster (one indirection less). On the other hand, when you need to put arbitrary stuff on temporary lists, usualy on more than one at a time, as is often done in glib, external lists are the only way. OT: > Yes, hashes are good. Simplify programming a lot. > I know only Perl language which support hashes in core, but it's on > arrays so perfomance isn't as good as wanted. Python does too. As does tcl. Most scripting languages do. C++ does too (there are hashes in STL (standard template library)). Yes, perl's performance on hashes is poor -- it's the only think where it's slower than python. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz>
Attachment:
signature.asc
Description: Digital signature