The Yalnix Kernel is an educational operating system implementing core OS functionalities including process management, virtual memory, synchronization primitives, and inter-process communication. Built for the Yalnix hardware architecture, it provides a foundation for understanding fundamental operating system concepts.
The kernel implements a two-region virtual memory system:
- Region 0: Kernel space (0x0 - VMEM_1_BASE)
- Region 1: User space (VMEM_1_BASE - VMEM_1_LIMIT)
Memory is managed through paged virtual memory with TLB support, handling memory protection, stack growth, and frame allocation.
Memory Layout:
┌───────────────┐VMEM_1_LIMIT
│ User Text │
│ User Data │
│ User Heap │
│ │
│ User Stack │
└───────────────┘
┌───────────────┐VMEM_1_BASE
│ Kernel Stack │
│ Kernel Heap │
│ Kernel Data │
│ Kernel Text │
└───────────────┘0x00000000
Processes are represented by Process Control Blocks (PCBs) that track:
- Process state (running, ready, blocked, defunct, orphan)
- Page tables and memory mappings
- Context information
- Parent-child relationships
- Resource allocations
The scheduler implements basic round-robin scheduling using ready and blocked queues.
The kernel provides three synchronization primitives:
- Locks: Mutex locks with wait queues
- Condition Variables: For process signaling
- Pipes: For data transfer between processes
All synchronization objects use a unified ID scheme with type flags (LOCK_ID_FLAG, CONDVAR_ID_FLAG, PIPE_ID_FLAG).
Terminal I/O is implemented through a TTY subsystem supporting:
- Buffered reads and writes
- Process blocking when resources unavailable
- Interrupt-driven I/O
The process subsystem manages the process lifecycle:
- Process creation and termination
- Basic parent-child relationship tracking
- Resource allocation and deallocation
- Context switches
Memory management provides:
- Frame allocation via bitmap
- Page table management
- Stack growth handling
- Memory access validation
- TLB management
The synchronization primitives include:
- Lock acquisition/release with blocking
- Condition variable wait/signal/broadcast
- Pipe read/write with appropriate blocking
The terminal I/O system handles:
- Read/write operations to terminals
- Process queues for blocked readers/writers
- Buffer management for input/output
A simple but effective queue implementation for:
- Process queues
- Wait queues
- TTY operation queues
The trap handler processes:
- System calls (via TrapKernelHandler)
- Clock interrupts (TrapClockHandler)
- Memory violations (TrapMemoryHandler)
- TTY I/O interrupts (TrapTtyReceiveHandler, TrapTtyTransmitHandler)
- Memory Protection: Strict validation of user pointers
- Resource ID Validation: Type and range checking for all IDs
- Address Space Isolation: Complete separation of user/kernel memory
- Buffer Validation: Boundary checking for all memory operations
# Build the kernel
make
# Run with no args (will run init)
./yalnix
# Run with specific program
./yalnix test_file- Process creation/context switching
- Virtual memory implementation
- System Calls
- Scheduling
- Synchronization
- IPC
- TTY I/O
Future Goals:
- Disk
- Interactive shell
- File system
Based on the Yalnix hardware framework developed by Dartmouth College's Department of Computer Science.