# danghuyenvu/os-assignment-242---hcmut architecture

> Architecture diagram of the GitHub repository danghuyenvu/os-assignment-242---hcmut, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danghuyenvu/os-assignment-242---hcmut
- Repository: https://github.com/danghuyenvu/os-assignment-242---hcmut

## Overview

This repository implements a teaching operating-system simulator. A configuration-driven loader admits processes; CPU workers dispatch and execute them on timer slots, while the scheduler manages ready processes. In paging mode, process memory uses virtual regions, page translation, physical RAM and swap; the memory library exposes allocation and byte access and invokes system calls for memory operations. The graph preserves syscall, legacy-memory and paging subsystems, but their internal wiring is limited where source was not excerpted; edges show only relationships visible in the excerpts or explicitly indexed references.

Main entry points: [`src/os.c`](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/os.c) (OS coordinator), [`include/syscall.h`](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/syscall.h) (Syscall definitions), [`include/mm.h`](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/mm.h) (Paging definitions), [`src/libmem.c`](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/libmem.c) (Memory library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["OS Runtime"]
  node_os["OS coordinator<br/>[os.c]"]
  node_timer["Timer events<br/>[timer.c]"]
  node_common_types["Shared process types<br/>[common.h]"]
  node_os_configuration["OS configuration<br/>[os-cfg.h]"]
  node_timer_interface["Timer interface<br/>[timer.h]"]
end

subgraph group_execution["Process Execution"]
  node_loader["Process loader<br/>[loader.c]"]
  node_scheduler["Process scheduler<br/>[sched.c]"]
  node_queue["Ready queues<br/>[queue.c]"]
  node_cpu["CPU execution<br/>[cpu.c]"]
  node_cpu_interface["CPU interface<br/>[cpu.h]"]
  node_loader_interface["Loader interface<br/>[loader.h]"]
  node_sched_interface["Scheduler interface<br/>[sched.h]"]
  node_queue_interface["Queue interface<br/>[queue.h]"]
end

subgraph group_memory["Memory Management"]
  node_legacy_memory["Legacy memory<br/>[mem.c]"]
  node_memory_library["Memory library<br/>[libmem.c]"]
  node_mm_core["Memory manager<br/>[mm.c]"]
  node_vm_paging["Virtual paging<br/>[mm-vm.c]"]
  node_physical_memory["Physical memory<br/>[mm-memphy.c]"]
  node_paging_adapter["Paging adapter<br/>[paging.c]"]
  node_memory_config["Memory configuration<br/>[os-mm.h]"]
  node_mem_interface["Legacy memory API<br/>[mem.h]"]
  node_libmem_interface["Memory library API<br/>[libmem.h]"]
  node_mm_interface["Paging definitions<br/>[mm.h]"]
  node_bit_operations["Bit operations<br/>[bitops.h]"]
end

subgraph group_syscalls["System Calls"]
  node_syscall_api["Syscall interface<br/>[syscall.c]"]
  node_memory_syscall["Memory syscalls<br/>[sys_mem.c]"]
  node_kill_syscall["Kill-all syscall<br/>[sys_killall.c]"]
  node_list_syscall["Syscall listing<br/>[sys_listsyscall.c]"]
  node_example_handler["Example handler<br/>[sys_xxxhandler.c]"]
  node_syscall_interface["Syscall definitions<br/>[syscall.h]"]
  node_standard_library["System library<br/>[libstd.c]"]
end

node_operator(("Simulator user"))

node_operator -.->|"starts"| node_os
node_os -->|"loads processes"| node_loader
node_os -->|"initializes"| node_scheduler
node_os -->|"starts events"| node_timer
node_os -->|"starts workers"| node_cpu
node_os -->|"initializes"| node_mm_core
node_os -->|"initializes"| node_physical_memory
node_memory_library -->|"invokes"| node_syscall_api
node_os -->|"uses configuration"| node_memory_config
node_os -->|"includes"| node_cpu_interface
node_os -->|"includes"| node_loader_interface
node_os -->|"includes"| node_sched_interface
node_os -->|"includes"| node_timer_interface
node_cpu -->|"implements"| node_cpu_interface
node_loader -->|"implements"| node_loader_interface
node_scheduler -->|"implements"| node_sched_interface
node_scheduler -->|"uses"| node_queue
node_queue -->|"implements"| node_queue_interface
node_legacy_memory -->|"implements"| node_mem_interface
node_memory_library -->|"implements"| node_libmem_interface
node_memory_library -->|"uses"| node_mm_interface
node_mm_core -->|"implements"| node_mm_interface
node_vm_paging -->|"implements"| node_mm_interface
node_physical_memory -->|"implements"| node_mm_interface
node_paging_adapter -->|"uses"| node_mem_interface
node_paging_adapter -->|"uses"| node_cpu_interface
node_paging_adapter -->|"uses"| node_loader_interface
node_mm_interface -->|"uses"| node_bit_operations
node_common_types -->|"includes"| node_os_configuration
node_common_types -->|"includes"| node_memory_config
node_syscall_api -->|"implements"| node_syscall_interface
node_memory_syscall -->|"uses"| node_syscall_interface
node_kill_syscall -->|"uses"| node_syscall_interface
node_list_syscall -->|"uses"| node_syscall_interface
node_example_handler -->|"uses"| node_syscall_interface
node_standard_library -->|"uses"| node_syscall_interface

click node_os "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/os.c"
click node_timer "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/timer.c"
click node_loader "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/loader.c"
click node_scheduler "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sched.c"
click node_queue "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/queue.c"
click node_cpu "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/cpu.c"
click node_legacy_memory "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mem.c"
click node_memory_library "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/libmem.c"
click node_mm_core "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm.c"
click node_vm_paging "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm-vm.c"
click node_physical_memory "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm-memphy.c"
click node_paging_adapter "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/paging.c"
click node_syscall_api "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/syscall.c"
click node_memory_syscall "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_mem.c"
click node_kill_syscall "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_killall.c"
click node_list_syscall "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_listsyscall.c"
click node_example_handler "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_xxxhandler.c"
click node_memory_config "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/os-mm.h"
click node_cpu_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/cpu.h"
click node_loader_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/loader.h"
click node_sched_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/sched.h"
click node_queue_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/queue.h"
click node_mem_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/mem.h"
click node_libmem_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/libmem.h"
click node_mm_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/mm.h"
click node_bit_operations "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/bitops.h"
click node_common_types "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/common.h"
click node_os_configuration "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/os-cfg.h"
click node_syscall_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/syscall.h"
click node_timer_interface "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/timer.h"
click node_standard_library "https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/libstd.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_os,node_timer,node_common_types,node_os_configuration,node_timer_interface,node_operator toneBlue
class node_loader,node_scheduler,node_queue,node_cpu,node_cpu_interface,node_loader_interface,node_sched_interface,node_queue_interface toneAmber
class node_legacy_memory,node_memory_library,node_mm_core,node_vm_paging,node_physical_memory,node_paging_adapter,node_memory_config,node_mem_interface,node_libmem_interface,node_mm_interface,node_bit_operations toneMint
class node_syscall_api,node_memory_syscall,node_kill_syscall,node_list_syscall,node_example_handler,node_syscall_interface,node_standard_library toneRose
```

## Components

### OS Runtime

- [OS coordinator](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/os.c): `src/os.c`
- [Timer events](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/timer.c): `src/timer.c`
- [Shared process types](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/common.h): `include/common.h`
- [OS configuration](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/os-cfg.h): `include/os-cfg.h`
- [Timer interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/timer.h): `include/timer.h`

### Process Execution

- [Process loader](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/loader.c): `src/loader.c`
- [Process scheduler](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sched.c): `src/sched.c`
- [Ready queues](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/queue.c): `src/queue.c`
- [CPU execution](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/cpu.c): `src/cpu.c`
- [CPU interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/cpu.h): `include/cpu.h`
- [Loader interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/loader.h): `include/loader.h`
- [Scheduler interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/sched.h): `include/sched.h`
- [Queue interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/queue.h): `include/queue.h`

### Memory Management

- [Legacy memory](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mem.c): `src/mem.c`
- [Memory library](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/libmem.c): `src/libmem.c`
- [Memory manager](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm.c): `src/mm.c`
- [Virtual paging](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm-vm.c): `src/mm-vm.c`
- [Physical memory](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/mm-memphy.c): `src/mm-memphy.c`
- [Paging adapter](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/paging.c): `src/paging.c`
- [Memory configuration](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/os-mm.h): `include/os-mm.h`
- [Legacy memory API](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/mem.h): `include/mem.h`
- [Memory library API](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/libmem.h): `include/libmem.h`
- [Paging definitions](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/mm.h): `include/mm.h`
- [Bit operations](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/bitops.h): `include/bitops.h`

### System Calls

- [Syscall interface](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/syscall.c): `src/syscall.c`
- [Memory syscalls](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_mem.c): `src/sys_mem.c`
- [Kill-all syscall](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_killall.c): `src/sys_killall.c`
- [Syscall listing](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_listsyscall.c): `src/sys_listsyscall.c`
- [Example handler](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/sys_xxxhandler.c): `src/sys_xxxhandler.c`
- [Syscall definitions](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/include/syscall.h): `include/syscall.h`
- [System library](https://github.com/danghuyenvu/os-assignment-242---hcmut/blob/main/src/libstd.c): `src/libstd.c`

### Other components

- **Simulator user**

## Connections

- Simulator user → OS coordinator: starts
- OS coordinator → Process loader: loads processes (evidence: `src/os.c`)
- OS coordinator → Process scheduler: initializes (evidence: `src/os.c`)
- OS coordinator → Timer events: starts events (evidence: `src/os.c`)
- OS coordinator → CPU execution: starts workers (evidence: `src/os.c`)
- OS coordinator → Memory manager: initializes (evidence: `src/os.c`)
- OS coordinator → Physical memory: initializes (evidence: `src/os.c`)
- Memory library → Syscall interface: invokes (evidence: `src/libmem.c`)
- OS coordinator → Memory configuration: uses configuration (evidence: `src/os.c`)
- OS coordinator → CPU interface: includes (evidence: `src/os.c`)
- OS coordinator → Loader interface: includes (evidence: `src/os.c`)
- OS coordinator → Scheduler interface: includes (evidence: `src/os.c`)
- OS coordinator → Timer interface: includes (evidence: `src/os.c`)
- CPU execution → CPU interface: implements (evidence: `src/cpu.c`)
- Process loader → Loader interface: implements (evidence: `src/loader.c`)
- Process scheduler → Scheduler interface: implements (evidence: `src/sched.c`)
- Process scheduler → Ready queues: uses (evidence: `src/sched.c`)
- Ready queues → Queue interface: implements (evidence: `src/queue.c`)
- Legacy memory → Legacy memory API: implements (evidence: `src/mem.c`)
- Memory library → Memory library API: implements (evidence: `src/libmem.c`)
- Memory library → Paging definitions: uses (evidence: `src/libmem.c`)
- Memory manager → Paging definitions: implements (evidence: `src/mm.c`)
- Virtual paging → Paging definitions: implements (evidence: `src/mm-vm.c`)
- Physical memory → Paging definitions: implements (evidence: `src/mm-memphy.c`)
- Paging adapter → Legacy memory API: uses (evidence: `src/paging.c`)
- Paging adapter → CPU interface: uses (evidence: `src/paging.c`)
- Paging adapter → Loader interface: uses (evidence: `src/paging.c`)
- Paging definitions → Bit operations: uses (evidence: `include/mm.h`)
- Shared process types → OS configuration: includes (evidence: `include/common.h`)
- Shared process types → Memory configuration: includes (evidence: `include/common.h`)
- Syscall interface → Syscall definitions: implements (evidence: `src/syscall.c`)
- Memory syscalls → Syscall definitions: uses (evidence: `src/sys_mem.c`)
- Kill-all syscall → Syscall definitions: uses (evidence: `src/sys_killall.c`)
- Syscall listing → Syscall definitions: uses (evidence: `src/sys_listsyscall.c`)
- Example handler → Syscall definitions: uses (evidence: `src/sys_xxxhandler.c`)
- System library → Syscall definitions: uses (evidence: `src/libstd.c`)
