# minhkhoavu2026/cse421-project2 architecture

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

- Interactive diagram: https://gitdiagram.com/minhkhoavu2026/cse421-project2
- Repository: https://github.com/minhkhoavu2026/cse421-project2

## Overview

This is a Pintos-style teaching operating-system kernel: its tree contains hardware drivers, kernel threads and synchronization, user-process support, and a filesystem. The central runtime path is user-program startup through process loading, with filesystem access backed by inodes and block devices; the syscall implementation is present but unsampled, so its dispatch path is not drawn. The README provides no capability details, and several device subsystems are represented by their source directories because their implementations were not excerpted.

Main entry points: [`src/userprog/process.c`](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/process.c) (Process management), [`src/threads/thread.c`](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/thread.c) (Thread scheduler), [`src/threads/init.c`](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/init.c) (Kernel initialization), [`src/devices/ide.c`](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/ide.c) (IDE controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Kernel core"]
  node_boot["Kernel initialization<br/>[init.c]"]
  node_scheduler["Thread scheduler<br/>[thread.c]"]
  node_sync["Synchronization<br/>[synch.c]"]
  node_interrupts["Interrupt handling<br/>[interrupt.c]"]
  node_pagealloc["Page allocation<br/>[palloc.c]"]
  node_memory["Virtual memory<br/>[pagedir.c]"]
end

subgraph group_devices["Hardware devices"]
  node_timer["Timer service<br/>[timer.c]"]
  node_block["Block devices<br/>[block.c]"]
  node_ide["IDE controller<br/>[ide.c]"]
  node_partitions["Disk partitions<br/>[partition.c]"]
  node_otherdevices["Other device drivers"]
end

subgraph group_user["User processes"]
  node_process["Process management<br/>[process.c]"]
  node_syscalls["System call interface<br/>[syscall.c]"]
  node_exceptions["User exceptions<br/>[exception.c]"]
  node_segments["Descriptor tables<br/>[gdt.c]"]
end

subgraph group_fs["Filesystem"]
  node_filesys["Filesystem operations<br/>[filesys.c]"]
  node_directories["Directories<br/>[directory.c]"]
  node_files["Open files<br/>[file.c]"]
  node_inodes["Inode storage<br/>[inode.c]"]
  node_freemap["Free-space map<br/>[free-map.c]"]
  node_formatutil["Filesystem utilities<br/>[fsutil.c]"]
end

node_user(("User program"))

node_boot -->|"initializes"| node_scheduler
node_boot -->|"starts"| node_process
node_boot -->|"initializes"| node_timer
node_boot -->|"initializes"| node_interrupts
node_scheduler -->|"yields through"| node_interrupts
node_scheduler -->|"activates"| node_process
node_scheduler -->|"uses"| node_sync
node_scheduler -->|"allocates pages"| node_pagealloc
node_timer -->|"registers handler"| node_interrupts
node_timer -->|"accounts ticks"| node_scheduler
node_ide -->|"registers disks"| node_block
node_ide -->|"scans disks"| node_partitions
node_ide -->|"waits using"| node_timer
node_ide -->|"synchronizes with"| node_sync
node_user -.->|"issues calls"| node_syscalls
node_syscalls -.->|"dispatches to"| node_process
node_process -->|"creates threads"| node_scheduler
node_process -->|"loads executable"| node_files
node_process -->|"sets up address space"| node_memory
node_process -->|"updates task state"| node_segments
node_process -->|"allocates pages"| node_pagealloc
node_filesys -->|"uses"| node_directories
node_directories -->|"opens"| node_inodes
node_inodes -->|"allocates sectors"| node_freemap
node_inodes -.->|"reads and writes"| node_block
node_formatutil -->|"invokes"| node_filesys
node_formatutil -->|"uses"| node_directories
node_formatutil -->|"uses"| node_files
node_exceptions -->|"registers handlers"| node_interrupts

click node_boot "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/init.c"
click node_scheduler "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/thread.c"
click node_sync "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/synch.c"
click node_interrupts "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/interrupt.c"
click node_pagealloc "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/palloc.c"
click node_memory "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/pagedir.c"
click node_timer "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/timer.c"
click node_block "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/block.c"
click node_ide "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/ide.c"
click node_partitions "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/partition.c"
click node_otherdevices "https://github.com/minhkhoavu2026/cse421-project2/tree/main/src/devices"
click node_process "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/process.c"
click node_syscalls "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/syscall.c"
click node_exceptions "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/exception.c"
click node_segments "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/gdt.c"
click node_filesys "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/filesys.c"
click node_directories "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/directory.c"
click node_files "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/file.c"
click node_inodes "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/inode.c"
click node_freemap "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/free-map.c"
click node_formatutil "https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/fsutil.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_boot,node_scheduler,node_sync,node_interrupts,node_pagealloc,node_memory,node_user toneBlue
class node_timer,node_block,node_ide,node_partitions,node_otherdevices toneAmber
class node_process,node_syscalls,node_exceptions,node_segments toneMint
class node_filesys,node_directories,node_files,node_inodes,node_freemap,node_formatutil toneRose
```

## Components

### Kernel core

- [Kernel initialization](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/init.c): `src/threads/init.c`
- [Thread scheduler](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/thread.c): `src/threads/thread.c`
- [Synchronization](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/synch.c): `src/threads/synch.c`
- [Interrupt handling](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/interrupt.c): `src/threads/interrupt.c`
- [Page allocation](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/threads/palloc.c): `src/threads/palloc.c`
- [Virtual memory](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/pagedir.c): `src/userprog/pagedir.c`

### Hardware devices

- [Timer service](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/timer.c): `src/devices/timer.c`
- [Block devices](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/block.c): `src/devices/block.c`
- [IDE controller](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/ide.c): `src/devices/ide.c`
- [Disk partitions](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/devices/partition.c): `src/devices/partition.c`
- [Other device drivers](https://github.com/minhkhoavu2026/cse421-project2/tree/main/src/devices): `src/devices`

### User processes

- [Process management](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/process.c): `src/userprog/process.c`
- [System call interface](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/syscall.c): `src/userprog/syscall.c`
- [User exceptions](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/exception.c): `src/userprog/exception.c`
- [Descriptor tables](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/userprog/gdt.c): `src/userprog/gdt.c`

### Filesystem

- [Filesystem operations](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/filesys.c): `src/filesys/filesys.c`
- [Directories](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/directory.c): `src/filesys/directory.c`
- [Open files](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/file.c): `src/filesys/file.c`
- [Inode storage](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/inode.c): `src/filesys/inode.c`
- [Free-space map](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/free-map.c): `src/filesys/free-map.c`
- [Filesystem utilities](https://github.com/minhkhoavu2026/cse421-project2/blob/main/src/filesys/fsutil.c): `src/filesys/fsutil.c`

### Other components

- **User program**

## Connections

- Kernel initialization → Thread scheduler: initializes (evidence: `src/threads/init.c`)
- Kernel initialization → Process management: starts (evidence: `src/threads/init.c`)
- Kernel initialization → Timer service: initializes (evidence: `src/threads/init.c`)
- Kernel initialization → Interrupt handling: initializes (evidence: `src/threads/init.c`)
- Thread scheduler → Interrupt handling: yields through (evidence: `src/threads/thread.c`)
- Thread scheduler → Process management: activates (evidence: `src/threads/thread.c`)
- Thread scheduler → Synchronization: uses (evidence: `src/threads/thread.c`)
- Thread scheduler → Page allocation: allocates pages (evidence: `src/threads/thread.c`)
- Timer service → Interrupt handling: registers handler (evidence: `src/devices/timer.c`)
- Timer service → Thread scheduler: accounts ticks (evidence: `src/devices/timer.c`)
- IDE controller → Block devices: registers disks (evidence: `src/devices/ide.c`)
- IDE controller → Disk partitions: scans disks (evidence: `src/devices/ide.c`)
- IDE controller → Timer service: waits using (evidence: `src/devices/ide.c`)
- IDE controller → Synchronization: synchronizes with (evidence: `src/devices/ide.c`)
- User program → System call interface: issues calls
- System call interface → Process management: dispatches to
- Process management → Thread scheduler: creates threads (evidence: `src/userprog/process.c`)
- Process management → Open files: loads executable (evidence: `src/userprog/process.c`)
- Process management → Virtual memory: sets up address space (evidence: `src/userprog/process.c`)
- Process management → Descriptor tables: updates task state (evidence: `src/userprog/process.c`)
- Process management → Page allocation: allocates pages (evidence: `src/userprog/process.c`)
- Filesystem operations → Directories: uses (evidence: `src/filesys/directory.c`)
- Directories → Inode storage: opens (evidence: `src/filesys/directory.c`)
- Inode storage → Free-space map: allocates sectors (evidence: `src/filesys/inode.c`)
- Inode storage → Block devices: reads and writes
- Filesystem utilities → Filesystem operations: invokes (evidence: `src/filesys/fsutil.c`)
- Filesystem utilities → Directories: uses (evidence: `src/filesys/fsutil.c`)
- Filesystem utilities → Open files: uses (evidence: `src/filesys/fsutil.c`)
- User exceptions → Interrupt handling: registers handlers (evidence: `src/userprog/exception.c`)
