# jjake-08/xv6-riscv architecture

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

- Interactive diagram: https://gitdiagram.com/jjake-08/xv6-riscv
- Repository: https://github.com/jjake-08/xv6-riscv

## Overview

xv6 is a teaching Unix-like operating system for multiprocessor RISC-V. Its principal workflow is a user program issuing system calls that the kernel handles while managing processes, memory, files, and devices. The graph highlights those domain areas and the kernel’s syscall boundary as an internal layer. The supplied excerpts chiefly expose interfaces and selected modules; unverified runtime links are dashed rather than presented as inspected call paths.

Main entry points: [`kernel/syscall.c`](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/syscall.c) (Syscall dispatch), [`kernel/sysfile.c`](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/sysfile.c) (File syscalls), [`kernel/fs.c`](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/fs.c) (Filesystem), [`user/sh.c`](https://github.com/jjake-08/xv6-riscv/blob/riscv/user/sh.c) (Command shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_userland["Userland"]
  node_shell["Command shell<br/>[sh.c]"]
  node_init["System init<br/>[init.c]"]
  node_userlib["User API<br/>[user.h]"]
  node_utilities["User utilities"]
end

subgraph group_kernel["Kernel services"]
  node_syscall["Syscall dispatch<br/>[syscall.c]"]
  node_sysfile["File syscalls<br/>[sysfile.c]"]
  node_exec["Program loading<br/>[exec.c]"]
  node_process["Process management<br/>[proc.c]"]
  node_traps["Trap handling<br/>[trap.c]"]
  node_memory["Virtual memory<br/>[vm.c]"]
end

subgraph group_storage["Storage"]
  node_files["File descriptors<br/>[file.c]"]
  node_filesystem[("Filesystem<br/>[fs.c]")]
  node_journal["Filesystem journal<br/>[log.c]"]
  node_blockcache["Block cache<br/>[bio.c]"]
end

subgraph group_platform["RISC-V platform"]
  node_disk["Virtio disk<br/>[virtio_disk.c]"]
  node_console["Console I/O<br/>[console.c]"]
  node_riscv["RISC-V interface<br/>[riscv.h]"]
end

node_user(("User"))

node_user -.->|"runs commands"| node_shell
node_init -.->|"starts shell"| node_shell
node_shell -.->|"uses API"| node_userlib
node_utilities -.->|"uses API"| node_userlib
node_userlib -.->|"requests services"| node_syscall
node_syscall -.->|"dispatches file calls"| node_sysfile
node_syscall -.->|"dispatches process calls"| node_process
node_syscall -.->|"dispatches exec"| node_exec
node_process -.->|"manages address spaces"| node_memory
node_traps -.->|"handles user calls"| node_syscall
node_sysfile -.->|"uses descriptors"| node_files
node_sysfile -.->|"accesses files"| node_filesystem
node_filesystem -.->|"logs updates"| node_journal
node_filesystem -.->|"reads blocks"| node_blockcache
node_blockcache -.->|"requests I/O"| node_disk
node_console -.->|"uses machine interface"| node_riscv
node_traps -.->|"uses machine interface"| node_riscv

click node_shell "https://github.com/jjake-08/xv6-riscv/blob/riscv/user/sh.c"
click node_init "https://github.com/jjake-08/xv6-riscv/blob/riscv/user/init.c"
click node_userlib "https://github.com/jjake-08/xv6-riscv/blob/riscv/user/user.h"
click node_utilities "https://github.com/jjake-08/xv6-riscv/tree/riscv/user"
click node_syscall "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/syscall.c"
click node_sysfile "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/sysfile.c"
click node_exec "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/exec.c"
click node_process "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/proc.c"
click node_traps "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/trap.c"
click node_memory "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/vm.c"
click node_files "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/file.c"
click node_filesystem "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/fs.c"
click node_journal "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/log.c"
click node_blockcache "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/bio.c"
click node_disk "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/virtio_disk.c"
click node_console "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/console.c"
click node_riscv "https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/riscv.h"

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_shell,node_init,node_userlib,node_utilities,node_user toneBlue
class node_syscall,node_sysfile,node_exec,node_process,node_traps,node_memory toneAmber
class node_files,node_filesystem,node_journal,node_blockcache toneMint
class node_disk,node_console,node_riscv toneRose
```

## Components

### Userland

- [Command shell](https://github.com/jjake-08/xv6-riscv/blob/riscv/user/sh.c): `user/sh.c`
- [System init](https://github.com/jjake-08/xv6-riscv/blob/riscv/user/init.c): `user/init.c`
- [User API](https://github.com/jjake-08/xv6-riscv/blob/riscv/user/user.h): `user/user.h`
- [User utilities](https://github.com/jjake-08/xv6-riscv/tree/riscv/user): `user`

### Kernel services

- [Syscall dispatch](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/syscall.c): `kernel/syscall.c`
- [File syscalls](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/sysfile.c): `kernel/sysfile.c`
- [Program loading](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/exec.c): `kernel/exec.c`
- [Process management](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/proc.c): `kernel/proc.c`
- [Trap handling](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/trap.c): `kernel/trap.c`
- [Virtual memory](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/vm.c): `kernel/vm.c`

### Storage

- [File descriptors](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/file.c): `kernel/file.c`
- [Filesystem](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/fs.c): `kernel/fs.c`
- [Filesystem journal](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/log.c): `kernel/log.c`
- [Block cache](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/bio.c): `kernel/bio.c`

### RISC-V platform

- [Virtio disk](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/virtio_disk.c): `kernel/virtio_disk.c`
- [Console I/O](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/console.c): `kernel/console.c`
- [RISC-V interface](https://github.com/jjake-08/xv6-riscv/blob/riscv/kernel/riscv.h): `kernel/riscv.h`

### Other components

- **User**

## Connections

- User → Command shell: runs commands
- System init → Command shell: starts shell
- Command shell → User API: uses API (evidence: `user/sh.c`)
- User utilities → User API: uses API (evidence: `user/usertests.c`)
- User API → Syscall dispatch: requests services
- Syscall dispatch → File syscalls: dispatches file calls
- Syscall dispatch → Process management: dispatches process calls
- Syscall dispatch → Program loading: dispatches exec
- Process management → Virtual memory: manages address spaces
- Trap handling → Syscall dispatch: handles user calls
- File syscalls → File descriptors: uses descriptors
- File syscalls → Filesystem: accesses files
- Filesystem → Filesystem journal: logs updates
- Filesystem → Block cache: reads blocks
- Block cache → Virtio disk: requests I/O
- Console I/O → RISC-V interface: uses machine interface (evidence: `kernel/console.c`)
- Trap handling → RISC-V interface: uses machine interface (evidence: `kernel/trap.c`)
