Systems study
Offline — showing the cached copy.
Home / OS Theory / 12. Data structures the kernel actually uses

12. Data structures the kernel actually uses

One-liner. Systems code picks structures for cache behaviour and concurrency, not big-O alone.

Memorize

  • Hash table: O(1) average; chaining vs open addressing; load factor controls collisions; Robin Hood hashing bounds probe length.
  • Radix tree (xarray): page cache lookup by index — no rebalancing, good locality.
  • Red-black tree: ordered intervals and timers; O(log n) with bounded height.
  • Skip list: probabilistic ordered map; used in Redis sorted sets, simpler concurrent variants.
  • Bloom filter: no false negatives, tunable false positives; m = −n ln p / (ln 2)² bits.
  • Ring buffer: fixed-size SPSC/MPMC queues; cache-friendly, no allocation.
  • LRU = hash map + intrusive doubly linked list; intrusive lists avoid per-entry allocation.
  • Slab/size-class allocators trade internal fragmentation for speed and O(1) allocation.
CHOOSING A STRUCTURE ORDERED LOOKUP rbtree skiplist INDEX LOOKUP radix tree hash MEMBERSHIP Bloom/cuckoo fi… QUEUE ring buffer intrusive list ALLOCATION slab free list bitmap
Choosing a structure

Trap. Picking a hash table for range queries, or a tree for pointer-chasing-free iteration. Do this. Match the access pattern: point lookup, ordered scan, membership, FIFO.

Check

A Bloom filter answers "definitely not present" with certainty. What does it trade away?