# rcore-os/tg-rcore-tutorial architecture

> Architecture diagram of the GitHub repository rcore-os/tg-rcore-tutorial, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rcore-os/tg-rcore-tutorial
- Repository: https://github.com/rcore-os/tg-rcore-tutorial

## Overview

This is a componentized Rust teaching repository for the progressive Tangram rCore Tutorial operating-system kernel. The principal workflow is to boot a chapter kernel, load and run user programs, and introduce operating-system mechanisms chapter by chapter—from traps and scheduling through virtual memory, processes, files, IPC/signals, and threads/synchronization. Reusable crates implement shared kernel layers; user programs exercise them, and a checker evaluates captured output. Relationships below rely on the README and shown source excerpts; unsampled implementations are represented only where documented.

Main entry points: [`tg-rcore-tutorial-ch6/src/main.rs`](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch6/src/main.rs) (Filesystem kernel), [`tg-rcore-tutorial-ch8/src/main.rs`](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch8/src/main.rs) (Threads and sync), [`tg-rcore-tutorial-ch1/src/main.rs`](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch1/src/main.rs) (Bare-metal boot), [`tg-rcore-tutorial-ch2/src/main.rs`](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch2/src/main.rs) (Batch and traps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chapters["Chapter kernels"]
  node_ch1["Bare-metal boot<br/>[main.rs]"]
  node_ch2["Batch and traps<br/>[main.rs]"]
  node_ch3["Multitasking<br/>[main.rs]"]
  node_ch4["Virtual memory<br/>[main.rs]"]
  node_ch5["Process management<br/>[main.rs]"]
  node_ch6["Filesystem kernel<br/>[main.rs]"]
  node_ch7["IPC and signals<br/>[main.rs]"]
  node_ch8["Threads and sync<br/>[main.rs]"]
end

subgraph group_components["Kernel components"]
  node_sbi["SBI services<br/>[lib.rs]"]
  node_console["Console output<br/>[lib.rs]"]
  node_context["Execution context<br/>[lib.rs]"]
  node_allocator["Kernel allocator<br/>[lib.rs]"]
  node_vm["Virtual memory<br/>[lib.rs]"]
  node_syscall["Syscall framework<br/>[lib.rs]"]
  node_tasks["Task management<br/>[thread_manager.rs]"]
  node_filesystem[("Teaching filesystem<br/>[layout.rs]")]
  node_sync["Sync primitives<br/>[lib.rs]"]
  node_signals["Signal handling<br/>[lib.rs]"]
end

subgraph group_userland["User programs"]
  node_user["User programs<br/>[lib.rs]"]
end

subgraph group_learning["Learning tools"]
  node_checker["Output checker<br/>[main.rs]"]
end

node_learner(("Learner"))
node_qemu(("QEMU output"))

node_learner -->|"studies first"| node_ch1
node_ch1 -->|"progresses to"| node_ch2
node_ch2 -->|"progresses to"| node_ch3
node_ch3 -->|"adds address spaces"| node_ch4
node_ch4 -->|"adds processes"| node_ch5
node_ch5 -->|"adds filesystem"| node_ch6
node_ch6 -->|"adds IPC signals"| node_ch7
node_ch7 -->|"adds threads sync"| node_ch8
node_ch1 -->|"uses SBI"| node_sbi
node_ch4 -->|"uses virtual memory"| node_vm
node_ch5 -->|"uses task management"| node_tasks
node_ch6 -->|"opens files"| node_filesystem
node_ch6 -->|"initializes allocator"| node_allocator
node_ch6 -->|"runs programs"| node_user
node_ch7 -->|"adds signal handling"| node_signals
node_ch8 -->|"adds synchronization"| node_sync
node_ch8 -->|"manages threads"| node_tasks
node_ch8 -->|"runs programs"| node_user
node_ch2 -.->|"uses syscall framework"| node_syscall
node_ch3 -.->|"switches contexts"| node_context
node_user -.->|"produces output"| node_qemu
node_qemu -->|"feeds captured output"| node_checker
node_learner -->|"checks results"| node_checker

click node_ch1 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch1/src/main.rs"
click node_ch2 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch2/src/main.rs"
click node_ch3 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch3/src/main.rs"
click node_ch4 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch4/src/main.rs"
click node_ch5 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch5/src/main.rs"
click node_ch6 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch6/src/main.rs"
click node_ch7 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch7/src/main.rs"
click node_ch8 "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch8/src/main.rs"
click node_sbi "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-sbi/src/lib.rs"
click node_console "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-console/src/lib.rs"
click node_context "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-context/src/lib.rs"
click node_allocator "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-alloc/src/lib.rs"
click node_vm "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-vm/src/lib.rs"
click node_syscall "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-syscall/src/lib.rs"
click node_tasks "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-task-manage/src/thread_manager.rs"
click node_filesystem "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-easy-fs/src/layout.rs"
click node_sync "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-sync/src/lib.rs"
click node_signals "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-signal-impl/src/lib.rs"
click node_user "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-user/src/lib.rs"
click node_checker "https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-checker/src/main.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ch1,node_ch2,node_ch3,node_ch4,node_ch5,node_ch6,node_ch7,node_ch8 toneBlue
class node_sbi,node_console,node_context,node_allocator,node_vm,node_syscall,node_tasks,node_filesystem,node_sync,node_signals toneAmber
class node_user toneMint
class node_checker toneRose
class node_learner,node_qemu toneIndigo
```

## Components

### Chapter kernels

- [Bare-metal boot](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch1/src/main.rs): `tg-rcore-tutorial-ch1/src/main.rs`
- [Batch and traps](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch2/src/main.rs): `tg-rcore-tutorial-ch2/src/main.rs`
- [Multitasking](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch3/src/main.rs): `tg-rcore-tutorial-ch3/src/main.rs`
- [Virtual memory](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch4/src/main.rs): `tg-rcore-tutorial-ch4/src/main.rs`
- [Process management](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch5/src/main.rs): `tg-rcore-tutorial-ch5/src/main.rs`
- [Filesystem kernel](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch6/src/main.rs): `tg-rcore-tutorial-ch6/src/main.rs`
- [IPC and signals](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch7/src/main.rs): `tg-rcore-tutorial-ch7/src/main.rs`
- [Threads and sync](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-ch8/src/main.rs): `tg-rcore-tutorial-ch8/src/main.rs`

### Kernel components

- [SBI services](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-sbi/src/lib.rs): `tg-rcore-tutorial-sbi/src/lib.rs`
- [Console output](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-console/src/lib.rs): `tg-rcore-tutorial-console/src/lib.rs`
- [Execution context](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-context/src/lib.rs): `tg-rcore-tutorial-kernel-context/src/lib.rs`
- [Kernel allocator](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-alloc/src/lib.rs): `tg-rcore-tutorial-kernel-alloc/src/lib.rs`
- [Virtual memory](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-kernel-vm/src/lib.rs): `tg-rcore-tutorial-kernel-vm/src/lib.rs`
- [Syscall framework](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-syscall/src/lib.rs): `tg-rcore-tutorial-syscall/src/lib.rs`
- [Task management](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-task-manage/src/thread_manager.rs): `tg-rcore-tutorial-task-manage/src/thread_manager.rs`
- [Teaching filesystem](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-easy-fs/src/layout.rs): `tg-rcore-tutorial-easy-fs/src/layout.rs`
- [Sync primitives](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-sync/src/lib.rs): `tg-rcore-tutorial-sync/src/lib.rs`
- [Signal handling](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-signal-impl/src/lib.rs): `tg-rcore-tutorial-signal-impl/src/lib.rs`

### User programs

- [User programs](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-user/src/lib.rs): `tg-rcore-tutorial-user/src/lib.rs`

### Learning tools

- [Output checker](https://github.com/rcore-os/tg-rcore-tutorial/blob/test/tg-rcore-tutorial-checker/src/main.rs): `tg-rcore-tutorial-checker/src/main.rs`

### Other components

- **Learner**
- **QEMU output**

## Connections

- Learner → Bare-metal boot: studies first (evidence: `README.md`)
- Bare-metal boot → Batch and traps: progresses to (evidence: `README.md`)
- Batch and traps → Multitasking: progresses to (evidence: `README.md`)
- Multitasking → Virtual memory: adds address spaces (evidence: `README.md`)
- Virtual memory → Process management: adds processes (evidence: `README.md`)
- Process management → Filesystem kernel: adds filesystem (evidence: `README.md`)
- Filesystem kernel → IPC and signals: adds IPC signals (evidence: `README.md`)
- IPC and signals → Threads and sync: adds threads sync (evidence: `README.md`)
- Bare-metal boot → SBI services: uses SBI (evidence: `README.md`)
- Virtual memory → Virtual memory: uses virtual memory (evidence: `README.md`)
- Process management → Task management: uses task management (evidence: `README.md`)
- Filesystem kernel → Teaching filesystem: opens files (evidence: `tg-rcore-tutorial-ch6/src/main.rs`)
- Filesystem kernel → Kernel allocator: initializes allocator (evidence: `README.md`)
- Filesystem kernel → User programs: runs programs (evidence: `README.md`)
- IPC and signals → Signal handling: adds signal handling (evidence: `README.md`)
- Threads and sync → Sync primitives: adds synchronization (evidence: `README.md`)
- Threads and sync → Task management: manages threads (evidence: `tg-rcore-tutorial-ch8/src/main.rs`)
- Threads and sync → User programs: runs programs (evidence: `README.md`)
- Batch and traps → Syscall framework: uses syscall framework
- Multitasking → Execution context: switches contexts
- User programs → QEMU output: produces output
- QEMU output → Output checker: feeds captured output (evidence: `tg-rcore-tutorial-checker/src/main.rs`)
- Learner → Output checker: checks results (evidence: `README.md`)
