| ▲ | arbitrandomuser 3 hours ago |
| what is an intrusive data structure? |
|
| ▲ | ahartmetz 2 hours ago | parent | next [-] |
| A container class that needs cooperation from the contained items, usually with special data fields. For example, a doubly linked list where the forward and back pointers are regular member variables of the contained items. Intrusive containers can avoid memory allocations (which can be a correctness issue in a kernel) and go well with C's lack of built-in container classes. They are somewhat common in C and very rare in C++ and Rust. |
| |
| ▲ | eru an hour ago | parent [-] | | At least for a double linked list you can probably get pretty far in terms of performance in the non-intrusive case, if your compiler unboxes the contained item into your nodes? Or are there benefits left in intrusive data structures that this doesn't capture? | | |
| ▲ | dzaima 23 minutes ago | parent [-] | | Storing the data in nodes doesn't work if the given structure may need to be in multiple linked lists, which iirc was a concern for the kernel? And generally I'd imagine it's quite a weird form for data structures for which being in a linked list isn't a core aspect (no clue what specifically the kernel uses, but I could imagine situations where where objects aren't in any linked list for 99% of time, but must be able to be chained in even if there are 0 bytes of free RAM ("Error: cannot free memory because memory is full" is probably not a thing you'd ever want to see)). |
|
|
|
| ▲ | ajuc 2 hours ago | parent | prev [-] |
| A data structure that requires you to change the data to use it. Like a linked list that forces you to add a next pointer to the record you want to store in it. |