ContinuumOS is a light-weight minimal i686 kernel for training purposes.
- 32-bit i686 Kernel
- VGA Text Mode Driver
- Keyboard Driver
- Interrupt Descriptor Table (IDT) and Interrupt Service Routines (ISR)
- Paging and Memory Management
- Kernel Heap
- Multitasking with Process Management
- Cooperative and Preemptive Scheduling
- Lottery-based Process Scheduling
- System Calls Interface
- Programmable Interrupt Controller (PIC)
- Programmable Interval Timer (PIT)
- IDE/ATA Hard Disk Driver (PIO mode)
- Block Device Abstraction Layer
- RamFS (simple RAM-based filesystem)
- FAT32 Filesystem (read-only support)
- Virtual File System (VFS) abstraction layer
- File operations: open, read, seek, close
- Directory listing and navigation
- Interactive shell with command history
- Simple text editor with save/load functionality
- Multi-process support with foreground/background switching
- Event-driven I/O with per-process event queues
- System calls interface
- Cooperative and preemptive multitasking
- Lottery-based scheduling algorithm with configurable tickets
- Per-process virtual memory with page directory isolation
- Event-driven process synchronization using hooks
- Process states: running, yielding, waiting for events
- I/O event queue system for keyboard and other input
- Foreground process management for keyboard focus
- System calls: yield, start_process, exit, poll/wait for I/O events
To build and run ContinuumOS, you will need the following tools:
- An
i686-elfcross-compiler toolchain (GCC, G++, AS) makeqemu-system-i386grub(for creating the bootable ISO)
To build the kernel, run the following command:
make allThis will create the kernel binary at kernel/kernel.bin.
To run the OS in QEMU with FAT32 disk support:
make runTo run without any attached disks:
make run-nodiskTo create a bootable ISO image and run it in QEMU:
make runisoThe ISO image will be created as kernel.iso.
To remove all build artifacts:
make cleanTo remove all artifacts including test disk images:
make clean-allTo recreate the test FAT32 disk image:
make test_fat32.imgThis creates a 16MB FAT32 disk with a test file FAT32README by copying from the pre-built template fat32_template.img.
Note: To rebuild the FAT32 template from scratch, you'll need mtools installed.
ls [path]- List directory contents (works with all mounted filesystems)cd <dir>- Change directorycat <file>- Display file contents (works with all mounted filesystems)touch <file>- Create a new filemkdir <dir>- Create a directoryrm <file>- Remove a filermdir <dir>- Remove a directorypwd- Print working directory
mount [type]- Mount a filesystem (e.g.,mount fat32)umount <mountpoint>- Unmount a filesystemfsinfo- Show mounted filesystem information
help- Show available commandsecho <text>- Print textuptime- Show system uptimehistory- Show command historyedit <file>- Edit a file (use.saveto save,.exitto quit)ps- List running processes (if implemented)meminfo- Display detailed memory usage information (physical memory, heap statistics, memory layout)free- Display memory usage summary in a Linux-style format
lsblk- List block devicesdisktest- Test disk reading functionality
ContinuumOS implements a cooperative and preemptive multitasking system with the following features:
Scheduling: Uses a lottery-based scheduling algorithm where each process has a configurable number of tickets. Processes with more tickets have a higher probability of being selected to run.
Process Structure: Each process maintains:
- CPU context (registers, stack pointer, instruction pointer)
- Isolated page directory for virtual memory
- Per-process kernel stack
- Event queue for I/O operations
- Hook system for event-driven synchronization
- Keyboard handler callback
Event-Driven Synchronization: Processes can register hooks to wait for specific events:
HOOK_TIMER: Wait for a specific logical timeHOOK_KEYBOARD: Wait for keyboard inputHOOK_IO: Wait for I/O operations
System Calls: User processes can interact with the kernel via software interrupts (int 0x80):
syscall_yield(): Voluntarily yield CPU to another processsyscall_yield_for_event(): Yield and wait for a specific eventsyscall_start_process(): Create and start a new processsyscall_exit(): Terminate the current processsyscall_poll_io_event(): Check for I/O events without blockingsyscall_wait_io_event(): Wait for an I/O event (blocking)
Foreground Process: The scheduler maintains a foreground process concept for keyboard input. Only the foreground process receives keyboard events directly.
.
├── boot/ # Bootloader assembly code
├── build/ # Build artifacts
├── include/ # Header files for the kernel and libc
│ └── kernel/ # Kernel subsystem headers
│ ├── process.h # Process management structures
│ ├── scheduler.h # Scheduler interface
│ ├── hooks.h # Event hooks system
│ └── ...
├── kernel/ # Kernel binaries
├── libc/ # A basic C library implementation
│ ├── include/
│ │ └── sys/
│ │ ├── syscall.h # System call interface
│ │ └── events.h # I/O event structures
│ ├── process.c # Process management helpers
│ └── ...
├── src/ # Source code for the kernel and utilities
│ ├── kernel/ # Kernel implementation
│ │ ├── process.cpp # Process management
│ │ ├── scheduler.cpp # Process scheduler
│ │ ├── syscalls.cpp # System call handlers
│ │ └── ...
│ ├── bin/ # User programs
│ │ └── test_proc.cpp # Test process
│ └── user/ # User-space applications
│ └── editor.cpp # Text editor process
├── test_fat32.img # Test FAT32 disk image
├── grub.cfg # GRUB configuration
├── linker.ld # Linker script
├── Makefile # Build script
└── README.md # This file