A Rust advanced and operating system introductory exercise repository in the style of rustlings.
Learn Rust concurrency programming, async programming, no_std development, and operating system core concepts through completing code and passing tests.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
6 modules, 23 exercises in total, from easy to advanced:
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_thread_spawn | thread::spawn, move closures, join |
| 2 | 02_mutex_counter | Arc<Mutex<T>>, shared state concurrency |
| 3 | 03_channel | mpsc::channel, multiple producer pattern |
| 4 | 04_process_pipe | Command, Stdio::piped(), process pipes |
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_mem_primitives | no_std memory primitives: memcpy, memset, memmove, strlen, strcmp |
| 2 | 02_bump_allocator | GlobalAlloc trait, Bump allocator, CAS-based thread safety |
| 3 | 03_free_list_allocator | Free-list allocator, intrusive linked list, first-fit strategy |
| 4 | 04_syscall_wrapper | Cross-arch syscall ABI (x86_64/aarch64/riscv64), inline assembly |
| 5 | 05_fd_table | File descriptor table, Arc<dyn File>, fd reuse strategy |
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_atomic_counter | AtomicU64, fetch_add, CAS loop |
| 2 | 02_atomic_ordering | Memory ordering, Release-Acquire, OnceCell |
| 3 | 03_spinlock | Spinlock implementation, compare_exchange, spin_loop |
| 4 | 04_spinlock_guard | RAII guard, Deref/DerefMut/Drop |
| 5 | 05_rwlock | Writer-priority read-write lock from scratch (no std::sync::RwLock) |
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_stack_coroutine | Callee-saved registers, stack frames, context switching |
| 2 | 02_green_threads | Green thread scheduler, cooperative scheduling, yield |
Module 4 only runs on riscv64. Run ./check.sh or use the oscamp CLI as with the rest of the repository — no separate scripts needed. See exercises/04_context_switch/README.md for details.
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_basic_future | Manual implementation of Future trait, Poll, Waker |
| 2 | 02_tokio_tasks | tokio::spawn, JoinHandle, concurrent tasks |
| 3 | 03_async_channel | tokio::sync::mpsc, async producer-consumer |
| 4 | 04_select_timeout | tokio::select!, timeout control, race execution |
| # | Exercise | Concepts |
|---|---|---|
| 1 | 01_pte_flags | SV39 PTE bit layout, bit operations to construct/parse page table entries |
| 2 | 02_page_table_walk | Single-level page tables, VPN/offset splitting, address translation, page faults |
| 3 | 03_multi_level_pt | SV39 three-level page tables, page table walk, huge pages (2MB) mapping |
| 4 | 04_tlb_sim | TLB lookup/insert/FIFO replacement, flush (all/by page/by ASID), MMU simulation |
# 1. Clone repository
git clone <repo-url> && cd oscamp-base-experiment
# 2. Build interactive CLI tool
cargo build -p oscamp-cli
# 3. Start interactive exercise mode (recommended)
./target/debug/oscamp watch
Built-in interactive terminal tool similar to rustlings, supporting real-time file watching and progress tracking:
oscamp # Start interactive watch mode (default)
oscamp watch # Same as above
oscamp list # View completion status of all exercises
oscamp check # Check all exercises in batch
oscamp run <pkg> # Run tests for specified exercise
oscamp hint <pkg> # View exercise hint
oscamp help # Show help
h — View hint for current exercisel — View list of all exercisesn / p — Next / Previous exerciser / Enter — Re-run testsq / Esc — Quit# Run tests for a specific exercise
cargo test -p thread_spawn
# View detailed output
cargo test -p thread_spawn -- --nocapture
# Check all exercises
cargo test --workspace
./target/debug/oscamp watch to enter interactive modesrc/lib.rs, read documentation to understand conceptstodo!() markers, complete code according to comment hintsh to view hints anytimeThis repository uses a CI pipeline to automatically score your exercises and submit results to the leaderboard.
MIT