# ohidreza0/xv6-smsl architecture

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

- Interactive diagram: https://gitdiagram.com/ohidreza0/xv6-smsl
- Repository: https://github.com/ohidreza0/xv6-smsl
- Video tour (about a minute): https://gitdiagram.com/ohidreza0/xv6-smsl/video

## Overview

xv6 is a teaching Unix-like operating system for RISC-V. Its principal workflow starts at the shell: a user command makes system calls, the kernel dispatches them to process, execution, and I/O services, and results reach the process through files, pipes, or devices. The graph also shows boot initialization and the storage path. README establishes the product and platform; sampled source supports the main boot, shell, process, VM, filesystem, and disk relationships. Other subsystem links reflect xv6’s documented structure and are kept at subsystem level.

Main entry points: [`kernel/main.c`](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/main.c) (Kernel startup), [`kernel/fs.c`](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/fs.c) (Inodes and paths), [`kernel/file.c`](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/file.c) (Open files), [`kernel/proc.c`](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/proc.c) (Process management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_userland["User environment"]
  node_shell["Shell<br/>[sh.c]"]
  node_init["Init process<br/>[init.c]"]
  node_utilities["User utilities<br/>[cat.c]"]
end

subgraph group_kernel_core["Kernel control"]
  node_trap["Trap handling<br/>[trap.c]"]
  node_dispatch["Syscall dispatch<br/>[syscall.c]"]
  node_proc["Process management<br/>[proc.c]"]
  node_sysproc["Process syscalls<br/>[sysproc.c]"]
  node_exec["Program execution<br/>[exec.c]"]
  node_boot["Kernel startup<br/>[main.c]"]
end

subgraph group_memory["Memory management"]
  node_vm["Virtual memory<br/>[vm.c]"]
  node_allocator["Page allocator<br/>[kalloc.c]"]
end

subgraph group_filesystem["Filesystem and I/O"]
  node_sysfile["File syscalls<br/>[sysfile.c]"]
  node_file["Open files<br/>[file.c]"]
  node_pipe["Pipes<br/>[pipe.c]"]
  node_fs["Inodes and paths<br/>[fs.c]"]
  node_log["Crash recovery log<br/>[log.c]"]
  node_cache["Block cache<br/>[bio.c]"]
end

subgraph group_hardware["Devices"]
  node_console["Console I/O<br/>[console.c]"]
  node_uart["UART driver<br/>[uart.c]"]
  node_disk["Virtio disk driver<br/>[virtio_disk.c]"]
end

node_operator(("User"))
node_disk_device[("Emulated disk")]

node_operator -->|"enters commands"| node_shell
node_init -->|"starts"| node_shell
node_shell -->|"issues syscalls"| node_trap
node_utilities -->|"issues syscalls"| node_trap
node_trap -->|"dispatches"| node_dispatch
node_dispatch -->|"routes process calls"| node_sysproc
node_dispatch -->|"routes file calls"| node_sysfile
node_sysproc -->|"manages processes"| node_proc
node_sysfile -->|"operates on descriptors"| node_file
node_sysfile -->|"resolves paths"| node_fs
node_proc -->|"manages address spaces"| node_vm
node_proc -->|"shares descriptors"| node_file
node_exec -->|"loads program memory"| node_vm
node_exec -->|"reads executable"| node_fs
node_file -->|"reads and writes inodes"| node_fs
node_file -->|"dispatches pipe I/O"| node_pipe
node_file -->|"dispatches device I/O"| node_console
node_fs -->|"records updates"| node_log
node_fs -->|"requests blocks"| node_cache
node_log -->|"writes log blocks"| node_cache
node_cache -->|"transfers buffers"| node_disk
node_disk -->|"reads and writes"| node_disk_device
node_console -->|"reads and writes"| node_uart
node_boot -->|"initializes"| node_proc
node_boot -->|"initializes"| node_vm
node_boot -->|"initializes"| node_cache
node_boot -->|"initializes"| node_fs
node_boot -->|"initializes"| node_disk
node_boot -->|"creates first process"| node_init

click node_shell "https://github.com/ohidreza0/xv6-smsl/blob/main/user/sh.c"
click node_init "https://github.com/ohidreza0/xv6-smsl/blob/main/user/init.c"
click node_utilities "https://github.com/ohidreza0/xv6-smsl/blob/main/user/cat.c"
click node_trap "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/trap.c"
click node_dispatch "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/syscall.c"
click node_proc "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/proc.c"
click node_sysproc "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/sysproc.c"
click node_exec "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/exec.c"
click node_sysfile "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/sysfile.c"
click node_file "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/file.c"
click node_pipe "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/pipe.c"
click node_fs "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/fs.c"
click node_log "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/log.c"
click node_cache "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/bio.c"
click node_vm "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/vm.c"
click node_allocator "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/kalloc.c"
click node_console "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/console.c"
click node_uart "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/uart.c"
click node_disk "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/virtio_disk.c"
click node_boot "https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/main.c"

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_utilities,node_operator toneBlue
class node_trap,node_dispatch,node_proc,node_sysproc,node_exec,node_boot,node_disk_device toneAmber
class node_vm,node_allocator toneMint
class node_sysfile,node_file,node_pipe,node_fs,node_log,node_cache toneRose
class node_console,node_uart,node_disk toneIndigo
```

## Components

### User environment

- [Shell](https://github.com/ohidreza0/xv6-smsl/blob/main/user/sh.c): `user/sh.c`
- [Init process](https://github.com/ohidreza0/xv6-smsl/blob/main/user/init.c): `user/init.c`
- [User utilities](https://github.com/ohidreza0/xv6-smsl/blob/main/user/cat.c): `user/cat.c`

### Kernel control

- [Trap handling](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/trap.c): `kernel/trap.c`
- [Syscall dispatch](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/syscall.c): `kernel/syscall.c`
- [Process management](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/proc.c): `kernel/proc.c`
- [Process syscalls](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/sysproc.c): `kernel/sysproc.c`
- [Program execution](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/exec.c): `kernel/exec.c`
- [Kernel startup](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/main.c): `kernel/main.c`

### Memory management

- [Virtual memory](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/vm.c): `kernel/vm.c`
- [Page allocator](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/kalloc.c): `kernel/kalloc.c`

### Filesystem and I/O

- [File syscalls](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/sysfile.c): `kernel/sysfile.c`
- [Open files](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/file.c): `kernel/file.c`
- [Pipes](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/pipe.c): `kernel/pipe.c`
- [Inodes and paths](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/fs.c): `kernel/fs.c`
- [Crash recovery log](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/log.c): `kernel/log.c`
- [Block cache](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/bio.c): `kernel/bio.c`

### Devices

- [Console I/O](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/console.c): `kernel/console.c`
- [UART driver](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/uart.c): `kernel/uart.c`
- [Virtio disk driver](https://github.com/ohidreza0/xv6-smsl/blob/main/kernel/virtio_disk.c): `kernel/virtio_disk.c`

### Other components

- **User**
- **Emulated disk**

## Connections

- User → Shell: enters commands
- Init process → Shell: starts
- Shell → Trap handling: issues syscalls
- User utilities → Trap handling: issues syscalls
- Trap handling → Syscall dispatch: dispatches
- Syscall dispatch → Process syscalls: routes process calls
- Syscall dispatch → File syscalls: routes file calls
- Process syscalls → Process management: manages processes
- File syscalls → Open files: operates on descriptors
- File syscalls → Inodes and paths: resolves paths
- Process management → Virtual memory: manages address spaces
- Process management → Open files: shares descriptors
- Program execution → Virtual memory: loads program memory
- Program execution → Inodes and paths: reads executable
- Open files → Inodes and paths: reads and writes inodes
- Open files → Pipes: dispatches pipe I/O
- Open files → Console I/O: dispatches device I/O
- Inodes and paths → Crash recovery log: records updates
- Inodes and paths → Block cache: requests blocks
- Crash recovery log → Block cache: writes log blocks
- Block cache → Virtio disk driver: transfers buffers
- Virtio disk driver → Emulated disk: reads and writes
- Console I/O → UART driver: reads and writes
- Kernel startup → Process management: initializes
- Kernel startup → Virtual memory: initializes
- Kernel startup → Block cache: initializes
- Kernel startup → Inodes and paths: initializes
- Kernel startup → Virtio disk driver: initializes
- Kernel startup → Init process: creates first process
