How ticonderoga2017/starry-next works
Project type and purpose
• StarryOS is a monolithic operating‐system kernel (written in Rust), derived from ArceOS, plus a suite of user‐space test applications and build/runtime tooling. It’s not a web app or microservice, but a low‐level OS kernel with a userland test harness.
File structure
• Top‐level crates and folders:
• src/ → the kernel’s entry point, main loop, syscall dispatcher, mm, task management
• core/ → core kernel library (futex, memory management, task structs, timers)
• api/ → user‐kernel interface crate (file, pipe, stdio, signal, networking abstractions)
• build.rs, Makefile, scripts/ → build pipeline, config generation, image creation
• configs/ → target‐specific TOML files (x86_64, riscv64, aarch64, loongarch64)
• apps/ → user applications grouped by test suite (libc, nimbos, junior, oscomp)
• .devcontainer, Dockerfile → developer container for consistent Rust/musl build environment
• .github/workflows → CI automation
• The project uses Cargo (Rust), Makefiles, shell scripts, Docker, QEMU.
README for additional insights
• Describes build & run recipes:
• Dependency fetch via scripts/get_deps.sh
• Building user apps, kernel, and creating disk image
• Running in QEMU with various architectures and features
Main components and their interactions
a. Developer & Build Environment
• Host machine → Docker container (or native)
• scripts/get_deps.sh → installs musl toolchains, qemu, cargo‐binutils
• Cargo + Makefiles + build.rs → compile core/, api/, and src/ crates into a kernel binary
• scripts/build_img.sh → packages user apps into a filesystem image
b. Kernel components (monolithic)
• Entry & init (src/entry.rs, main.rs)
• System call layer (src/syscall.rs)
• Memory management (src/mm.rs; core/src/mm.rs; api/src/imp/mm)
• Task & scheduler (core/src/task.rs; api/src/imp/task)
• File system & I/O (api/src/file, api/src/imp/fs)
• Signals, futex (api/src/imp/signal.rs; api/src/imp/futex.rs)
• Time & timers (api/src/time.rs; core/src/time.rs)
c. User‐space applications
• Built under apps/… → static binaries for each architecture
• Link against api crate interfaces (syscalls)
d. QEMU VM
• Loads kernel binary + disk image (with apps)
• Simulates hardware: CPU, memory, block (BLK), network (NET), acceleration (ACCEL)
Architectural patterns & design principles
• Modular monolith: each subsystem lives in its own Rust module/crate but linked into one kernel binary
• Clear crate‐level API boundary: core (kernel internals), api (public syscall interface), src (glue code)
• Host ↔ Target separation: host tools build, then produce artifacts for target QEMU runtime
• Cross‐compilation via musl toolchains ensures portability across four CPU architectures.
• Clear labels on every component (e.g., “api crate”, “core crate”, “scheduler module”)
• Build pipeline (source → compiler → binary)
• Runtime syscalls and I/O paths