TWCOS Kernel


Slab Allocator


The slab allocator provides the following main features:

Object types

Custom object allocation is achieved by creating a type definition. The type definition includes:


static slab_type_t threads[1] = {SLAB_TYPE(sizeof(thread_t), thread_mark, thread_finalize)}; ... thread_t * thread = slab_calloc(threads);

Garbage collection

The garbage collector is currently a simple mark and sweep collector, with a depth first traversal of reachable heap objects from a set of root objects. The root objects comprise:

The collector is a conservative collector, interpreting root objects as pointers, and marking any pointers that point into the heap space. The result being that a non-pointer value that happens to point into the heap will result in the heap spaces "pointed" to by that non-pointer being marked as reachable and not garbage.