Angus |
02-12-2011 04:12 PM |
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++: - What's rcu? And I'll probably need to know what "rcu protection" is too
- 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
- 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?
|