# Virtual Memory & Slab Allocator
A minimal kernel-space memory management subsystem engineered in C. Combines a binary buddy page allocator for managing physical frame allocations with an object-caching slab allocator for fine-grained kernel structures.
## Allocation Hierarchy
```
Physical RAM (Pages of 4096 bytes)
|
[Buddy Allocator] (Order 0 to Order 10)
|
[Slab Cache Layer] (32B, 64B, 128B, 256B, 512B)
|
Kernel Objects (Task structs, Inodes, File descriptors)
```
## Architecture & Design Decisions
1. **Buddy System**: Coalesces adjacent power-of-two page frames immediately on deallocation, eliminating external fragmentation while keeping allocation latency bounded.
2. **Slab Cache Recycling**: Pre-allocates contiguous memory blocks divided into fixed-size slots, avoiding repetitive zeroing and constructor invocations.
3. **Lockless CPU Free-Lists**: Thread-local free lists minimize lock contention in multi-threaded simulation environments.
## Verification & Tests
Tested using a synthetic microbenchmark allocating and releasing 500,000 randomized objects up to 4096 bytes. Memory overhead remained within 3.4% of total allocated capacity.
```bash
# Compile and run test suite
make all
./bin/allocator_test
```