Tosin RTOS is a 32-bit x86 educational real-time operating system built from scratch in C and assembly. It boots via a custom 512-byte MBR bootloader, switches to protected mode, initializes timer interrupts, and runs a preemptive priority scheduler with a shell task.
The repository already includes a working end-to-end path:
- Bootloader loads kernel sectors from disk and enters protected mode.
- Kernel initializes memory management and scheduler.
- Idle and shell tasks are created at boot.
- Timer-driven preemptive scheduling is active.
- IPC primitives (semaphores and queues) are integrated.
- Interactive shell commands are available for runtime inspection and testing.
- Custom MBR bootloader in boot/boot.asm
- Real mode to protected mode transition with GDT setup
- A20 enable sequence
- Kernel load to physical address 0x8000
- Boot signature 0xAA55
- Kernel entry and low-level setup in kernel/core/entry.asm
- IDT setup and PIC remap
- PIT programmed for 100 Hz timer ticks
- Assembly context switching via context_switch
- Task model and lifecycle in kernel/core/task.c
- Scheduler in kernel/core/scheduler.c
- Preemptive, priority-based round-robin scheduling
- 16 priority levels (0 through 15)
- Tick-based sleeping with task_sleep
- Heap allocator in kernel/mm/memory.c
- Best-fit allocation strategy
- Block splitting and free-block coalescing
- 8-byte alignment
- Runtime usage stats via mem_get_total, mem_get_used, and mem_get_free
- Counting semaphores with wait queues in kernel/ipc/semaphore.c
- Circular-buffer message queues in kernel/ipc/queue.c
- Timeout-aware wait/send/receive APIs
- VGA text output and keyboard input in lib/io.c
- Command shell in shell/shell.c
- Built-in commands:
- help
- clear
- meminfo
- ps
- echo
- uname
- test
System defaults are defined in include/config.h:
- MAX_TASKS: 32
- TASK_STACK_SIZE: 4096 bytes
- TIMER_FREQ_HZ: 100
- TIME_SLICE_MS: 10
- HEAP_SIZE: 1 MiB
- MAX_PRIORITY: 15
- QUEUE_SIZE: 16
- SHELL_BUFFER_SIZE: 256
This project is built with GNU toolchain-style utilities (Makefile uses dd, rm, ls). Recommended environments:
- Linux
- WSL on Windows
Required tools:
- nasm
- gcc with 32-bit support
- ld
- objcopy
- make
- qemu-system-i386 (for emulation)
Build:
make
Run:
make run
Debug (QEMU gdb stub):
make debug
Optional build verification script:
./build.sh
- BIOS loads MBR at 0x7C00.
- Bootloader in boot/boot.asm loads kernel sectors and enables protected mode.
- Kernel entry in kernel/core/entry.asm sets interrupt/timer hardware.
- Kernel main in kernel/core/main.c:
- initializes heap
- initializes scheduler
- creates idle task (priority 0)
- creates shell task (priority 5)
- starts scheduler
For deeper detail, see:
- 32-bit x86 only
- No user/kernel isolation
- No virtual memory or paging subsystem
- No filesystem or networking stack
- Shell is minimal and command set is intentionally small
Typical extension points:
- Add new shell commands in shell/shell.c
- Add or modify kernel services under kernel
- Tune system constants in include/config.h
Provided for educational and development use.