5 ms·
> It's so popular because it's the only data structure that is easy to use in C. Is this reasoning really true? A quick search reveals the availability of hig
by LexiMax 1y ago
> It's so popular because it's the only data structure that is easy to use in C.
Is this reasoning really true? A quick search reveals the availability of higher-level data structures like trees, flexible arrays, hashtables, and the like, so it's not as if the linux kernel is lacking in data structures.
Linked lists have a few other advantages - simplicity and reference stability come to mind, but they might have other properties that makes them useful for kernel development beyond how easy they are to create.
- a-dub 1y agothere's a whole library inside linux and it's really good too!
- cyberax 1y ago> Is this reasoning really true? Well, yes. The kernel _now_ has all kinds of data structures, but you can look at the documentation from 2006 and see the horror of even the simplest rbtrees back then: https://lwn.net/Articles/184495/ https://lwn.net/Articles/184495/ A simple generic hashtable was added only in 2013! > Linked lists have a few other advantages - simplicity and reference stability come to mind, but they might have other properties that makes them useful for kernel development beyond how easy they are to create. The main property is that it's easy to use from C. Think about growable vectors as an exercise.
- koverstreet 1y agoWhere do I find a basic vector type? :)
- cyberax 1y agoWhy, right here: https://elixir.bootlin.com/linux/v6.16.9/source/rust/kernel/alloc/kvec.rs https://elixir.bootlin.com/linux/v6.16.9/source/rust/kernel/... ! (XArray in regular C-based Linux also kinda qualifies)