Skip to main content

What is a Microkernel?

A microkernel is a minimalist approach to operating system design where the kernel provides only the most essential services:
  • Process and thread management
  • Memory management (virtual memory, paging)
  • Inter-process communication (IPC)
  • Basic I/O and interrupt handling
All other services—device drivers, file systems, network stacks—run in userspace as separate processes.
The Redox kernel is approximately 20,000 lines of code, compared to the Linux kernel’s 20+ million lines.

Microkernel vs Monolithic Kernel

Monolithic Architecture (Linux, BSD)

Characteristics:
  • Everything runs in kernel mode with full privileges
  • Fast: minimal context switches
  • Less secure: any bug can crash the system
  • Complex: tight coupling between components

Microkernel Architecture (Redox)

Characteristics:
  • Minimal kernel with most services in userspace
  • Strong isolation between components
  • More secure: bugs are contained
  • Modular: easy to replace components
Microkernel design trades some performance for significantly improved reliability, security, and maintainability.

Redox Microkernel Features

1. Process Management

The kernel manages processes with minimal overhead:
// Kernel provides basic process primitives
pub struct Process {
    pid: ProcessId,
    memory: AddressSpace,
    threads: Vec<Thread>,
    scheme_namespace: SchemeNamespace,
    // Minimal state
}

Process Creation

Efficient fork() and exec() system calls with copy-on-write memory

Process Isolation

Each process has its own address space and scheme namespace

2. Memory Management

The kernel handles virtual memory and paging:
  • Virtual address spaces: Each process has isolated memory
  • Demand paging: Pages loaded on access
  • Copy-on-write: Efficient fork() implementation
  • Memory mapping: mmap() for file and device access
// Kernel memory management interface
pub trait MemoryScheme {
    fn allocate(&mut self, size: usize) -> Result<PhysicalAddress>;
    fn map(&mut self, virt: VirtualAddress, phys: PhysicalAddress) -> Result<()>;
    fn unmap(&mut self, virt: VirtualAddress) -> Result<()>;
}

3. Inter-Process Communication (IPC)

Redox uses schemes as the primary IPC mechanism:
Applications communicate with services through scheme URLs like tcp:, file:, display:
High-performance IPC using shm: scheme for large data transfers
Channel-based communication using chan: scheme
POSIX-compatible uds_stream: and uds_dgram: schemes

4. Scheduling

The kernel implements a round-robin scheduler with priorities:
// Simplified scheduler logic
loop {
    let next_thread = scheduler.select_next();
    context_switch(current_thread, next_thread);
    current_thread = next_thread;
}
Redox’s scheduler is preemptive and supports multiple CPU cores with load balancing.

Advantages of Microkernel Design

1. Fault Isolation and Reliability

# Driver crash in Redox
$ ls /disk/file
# Driver crashes
[kernel] Driver 'disk' crashed, restarting...
# System continues running
$ ls /disk/file  # Works after restart
In monolithic kernels, a single driver bug can crash the entire system. In Redox, driver crashes are isolated and recoverable.

2. Security Through Least Privilege

Each service runs with minimal permissions:
# User permissions from base.toml
[user_schemes.user]
schemes = [
  # Kernel schemes (limited)
  "debug", "event", "memory", "pipe",
  
  # Utility schemes
  "rand", "null", "zero", "log",
  
  # Network schemes
  "ip", "icmp", "tcp", "udp",
  
  # File access
  "file",
  
  # User interfaces
  "pty", "audio", "orbital"
]

3. Modularity and Maintainability

1

Independent Development

Services can be developed and tested separately from the kernel
2

Easy Updates

Update individual services without rebuilding the kernel
3

Component Replacement

Swap implementations (e.g., replace file system) without kernel changes
4

Simplified Debugging

Debug services with standard userspace tools

4. Memory Safety with Rust

Redox leverages Rust’s memory safety guarantees:
// This won't compile - Rust prevents use-after-free
let data = vec![1, 2, 3];
let reference = &data[0];
drop(data);  // Error: cannot move out of `data` while borrowed
println!("{}", reference);

No Buffer Overflows

Rust’s bounds checking prevents buffer overruns

No Null Pointers

Rust’s Option type eliminates null pointer dereferences

No Data Races

Rust’s ownership system prevents concurrent access bugs

No Use-After-Free

Rust’s lifetime system ensures memory is valid

Performance Considerations

Context Switch Overhead

Microkernel architectures require more context switches:
Modern optimizations like message batching, zero-copy transfers, and efficient IPC mechanisms minimize the performance impact of context switches.

Optimization Techniques

Use shm: scheme for high-bandwidth data transfers without copying
Group multiple operations into single IPC messages
Direct memory mapping for network and disk I/O
Optimized syscall interface with minimal overhead

Kernel System Calls

Redox provides a minimal set of system calls:
// Core system calls in Redox kernel
pub enum SysCall {
    // Process management
    Exit(usize),
    Fork,
    Exec { path: &str, args: &[&str] },
    
    // Memory management
    Mmap { addr: usize, size: usize, flags: MapFlags },
    Munmap { addr: usize, size: usize },
    
    // Scheme operations
    Open { path: &str, flags: OpenFlags },
    Close { fd: FileDescriptor },
    Read { fd: FileDescriptor, buf: &mut [u8] },
    Write { fd: FileDescriptor, buf: &[u8] },
    
    // IPC
    Pipe { fds: &mut [FileDescriptor; 2] },
    Clone { flags: CloneFlags },
    Yield,
}
All I/O operations go through scheme handlers, not directly through the kernel.

Real-World Example: Disk Access

Here’s how disk access works in Redox’s microkernel:
// Application code
use std::fs::File;
use std::io::Write;

fn main() -> std::io::Result<()> {
    // 1. App opens file (scheme: "file:/path/to/file")
    let mut file = File::create("/disk/data.txt")?;
    
    // 2. Kernel routes to file system service
    // 3. File system service routes to disk driver
    // 4. Disk driver performs hardware I/O
    
    file.write_all(b"Hello, Redox!")?;
    Ok(())
}

Comparison with Other Microkernels

FeatureRedoxMINIX 3seL4QNX
LanguageRustCCC
Memory SafetyYesNoVerifiedNo
LicenseMITBSDGPLv2/CommercialCommercial
POSIX SupportVia relibcYesLimitedYes
Target UseGeneral purposeEducation/EmbeddedCritical systemsReal-time/Embedded
IPC MechanismSchemesMessagesEndpointsMessages
Redox combines the safety of Rust with the elegance of Plan 9’s everything-is-a-file design, creating a modern, secure microkernel OS.

Next Steps

System Components

Learn about userspace services and components

Scheme System

Understand Redox’s everything-is-a-URL design

Build docs developers (and LLMs) love