How sysprog21/linmo works
Project type and purpose
• Linmo is a monolithic, educational, multi-tasking OS kernel for RV32I (RISC-V).
• It provides preemptive/cooperative scheduling, a minimal C library, IPC primitives, dynamic memory, and a HAL to abstract hardware.
• Example applications live in app/ and run on QEMU.
File structure
Top-level folders:
• arch/riscv/ – RISC-V HAL: startup code, CSR handling, PMP, linker script.
• kernel/ – core scheduler, task management, IPC (mutex, semaphores, pipes), syscalls.
• lib/ & include/lib/ – minimal C library implementation (malloc, printf, etc.).
• app/ – user programs linking against liblinmo.a.
• include/ – public/kernel headers (syscall.h, task APIs, IPC APIs).
• Makefile, mk/ – build system that produces liblinmo.a, example binaries, and QEMU run targets.
README for architecture insights
• “Hardware Abstraction Layer (HAL)” – separates arch-specific from portable code.
• “Shared single address space” – all tasks plus kernel share memory.
• “Scheduler” – priority‐based round-robin, preemptive via timer interrupts in HAL.
• IPC primitives – implemented inside the kernel layer.
Main components and relationships
– Hardware (RISC-V CPU + memory + timer + PMP unit)
– HAL layer (arch/riscv/*.c, arch/riscv/*.h)
– Kernel core (kernel/*.c)
– C library (lib/*.c, include/lib/*.h)
– System Call / IPC interface (include/sys/*, kernel/syscall.c)
– Applications (app/*.c)
– Build & Test tools (Makefile, scripts, QEMU emulator)
b. Interactions:
– Apps → link → C library → invoke syscalls
– Syscalls → trap/interrupt → kernel dispatcher → kernel services (task, IPC, mem)
– Kernel → calls HAL for context switch, interrupt handling, hardware config (CSR, PMP)
– HAL → toggles hardware registers, sets up timer interrupts
– Build system → cross-compiles code → produces liblinmo.a and application binaries → QEMU
c. Architectural patterns:
– Layered monolithic kernel: HAL at the bottom, kernel services in the middle, C library & system calls on top, apps at the highest level.
– Single address space—no MMU, but optional PMP memory protection.
– Preemptive/cooperative scheduler implemented via HAL-driven timer interrupts.
d. Key technologies & frameworks:
– RISC-V RV32I, QEMU
– GNU toolchain (riscv-none-elf-gcc)
– Makefile + mk/common.mk
– C codebase, no external dependencies
Detail checklist (do not omit)
• All top-level modules (arch/riscv, kernel, lib, app)
• Build artifacts (liblinmo.a, Makefile targets, QEMU emulator)
• Memory model: heap, per-task stacks, shared address space
• IPC primitives as sub-components of kernel (mutexes, semaphores, pipes, mqueues)
• Scheduling modes (cooperative vs preemptive) as configuration in HAL/kernel