LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-12-2011, 04:12 PM   #1
Angus
LQ Newbie
 
Registered: Nov 2009
Location: Ottawa, Canada
Distribution: Ubuntu
Posts: 14

Rep: Reputation: 0
Questions about linked list


I'm looking through the source code for the linked list in <linux/list.h> and I have a few questions. You should probably know that I've never done any kernel writing, and the only C I've been doing for the past 10 years is C++:
  1. What's rcu? And I'll probably need to know what "rcu protection" is too
  2. Why no payload? It seems that the only members of list_head are next and prev. Where does the data go? Or is this the C kernel implementation of what would otherwise be a C++ template? I suppose to insert the payload, there's some clever code to find where list_head members end, and the payload is put there
  3. Why poison the next and prev when deleting a node? This seems awfully inefficient debug code. I might do such a thing in an application, but surround the code with #ifndef NDEBUG and then use asserts later. And why poison it to those values? Can there be no danger that those would be addresses assigned to pointers?
 
Old 02-14-2011, 02:31 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
Searching list_for_each_entry keyword in kernel source, you can find out a lot of example. They can explain why linked list doesn't have payload field.
 
Old 02-14-2011, 03:15 PM   #3
Angus
LQ Newbie
 
Registered: Nov 2009
Location: Ottawa, Canada
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: 0
I'm afraid I didn't. I did find http://isis.poly.edu/kulesh/stuff/src/klist/ which explains how to dereference the payload, by not why it's designed like that.

I'm guessing that it is designed this way, so that when forward traversing a list, the next pointer is at the same address as the current list struct, thereby avoiding the burden of having to calculate next's address. But that doesn't sound terribly useful.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked list C exvor Programming 14 06-22-2007 06:06 PM
linked list traversal Deepak Inbasekaran Programming 3 05-16-2007 10:33 PM
Linked list manas_sem Programming 3 12-21-2006 01:53 AM
C linked list exvor Programming 4 04-28-2006 05:25 AM
linked list + c dilberim82 Programming 5 05-04-2005 11:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration