# nguyenhuy0206/os_assignment architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenhuy0206/os_assignment
- Repository: https://github.com/nguyenhuy0206/os_assignment

## Overview

##### Project type and purpose
- This is a C-based operating-system simulator (OS_Assignment) used for academic OS coursework. It reads input job traces (process descriptions, scheduling scenarios, paging scenarios), runs through kernel‐module simulations (CPU, loader, scheduler, memory management, paging, timer, queues), and writes out behavior logs to an output directory.

##### File structure
- Top-level directories:
- / – public headers defining interfaces for each OS module (cpu, loader, mem, mm, sched, timer, queue, paging).
- src/ – implementation (.c) files for each module.
- input/ – test workloads (process lists, scheduling scenarios, paging scenarios).
- output/ – simulator’s logging results.
- obj/ – compiled object files (intermediate build artifacts).
- os/ – built executable lives here.
- Makefile orchestrates build: compiles src/*.c into obj/*.o, then links into the “os” binary.

##### Detail
- Don’t over-simplify: show sub-components inside Memory (physical allocator vs. VM/paging).
- Every module defined in include/ and src/.
- Clearly how test inputs map to simulation paths and how outputs are generated.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External I/O
    Input["Input Scenarios\ndirectory"]:::external
    Output["Output Logs\ndirectory"]:::external

    %% Core Simulation Engine
    subgraph "Simulation Engine" 
        direction TB
        OS["Core OS Executable\n(os.c)"]:::core
        Loader["Loader Module\n(loader.c)"]:::loader
        CPU["CPU Module\n(cpu.c)"]:::cpu
    end

    %% Scheduling Domain
    subgraph "Scheduling" 
        direction TB
        Scheduler["Scheduler Module\n(sched.c)"]:::sched
        Queue["Queue Module\n(queue.c)"]:::queue
    end

    %% Memory Domain
    subgraph "Memory Management"
        direction TB
        MemRaw["Raw Memory Ops\n(mem.c)"]:::mem
        subgraph "Physical & Virtual"
            direction TB
            MMPhy["Physical Allocator\n(mm-memphy.c)"]:::mmphy
            MMVM["Virtual/Paging Manager\n(mm-vm.c)"]:::mmvm
        end
        MMUnified["Unified MM Stub\n(mm.c)"]:::mem
        Paging["Paging Module\n(paging.c)"]:::paging
    end

    %% Timer Module
    Timer["Timer Module\ntimer.c"]:::timer

    %% Build Process
    subgraph "Build" 
        direction TB
        Makefile["Makefile"]:::external
        Obj["Object Files\n(obj/*.o)"]:::external
    end

    %% Flows
    Input -->|provides traces| Loader
    Loader -->|initializes| OS
    OS --> CPU
    OS --> Scheduler
    OS --> MemRaw
    OS --> Timer
    Scheduler -->|enqueue/dequeue| Queue
    CPU -->|dispatch/context switch| Scheduler
    CPU -->|memory access| MemRaw
    MemRaw --> MMPhy
    MemRaw --> MMVM
    MMPhy --> MMUnified
    MMVM --> MMUnified
    MMUnified --> Paging
    Timer -->|tick interrupt| CPU
    OS -->|writes logs| Output

    %% Build flows
    Makefile --> Obj
    Obj --> OS

    %% Click Events
    click Loader "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/loader.h"
    click Loader "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/loader.c"
    click CPU "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/cpu.h"
    click CPU "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/cpu.c"
    click Scheduler "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/sched.h"
    click Scheduler "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/sched.c"
    click Queue "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/queue.h"
    click Queue "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/queue.c"
    click MemRaw "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/mem.h"
    click MemRaw "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/mem.c"
    click MMPhy "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/mm.h"
    click MMPhy "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/mm-memphy.c"
    click MMVM "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/os-mm.h"
    click MMVM "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/mm-vm.c"
    click MMUnified "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/mm.c"
    click Paging "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/paging.c"
    click Timer "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/include/timer.h"
    click Timer "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/timer.c"
    click OS "https://github.com/nguyenhuy0206/os_assignment/blob/main/ossim_source_code/src/os.c"
    click Makefile "https://github.com/nguyenhuy0206/os_assignment/tree/main/ossim_source_code/Makefile"
    click Obj "https://github.com/nguyenhuy0206/os_assignment/tree/main/ossim_source_code/obj"
    click Input "https://github.com/nguyenhuy0206/os_assignment/tree/main/ossim_source_code/input"
    click Output "https://github.com/nguyenhuy0206/os_assignment/tree/main/ossim_source_code/output"

    %% Styles
    classDef loader fill:#a2cffe,stroke:#000,stroke-width:1px
    classDef cpu fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef sched fill:#b6e2a1,stroke:#000,stroke-width:1px
    classDef queue fill:#b6e2a1,stroke:#000,stroke-width:1px
    classDef mem fill:#ffd59e,stroke:#000,stroke-width:1px
    classDef mmphy fill:#ffbc7d,stroke:#000,stroke-width:1px
    classDef mmvm fill:#ffbc7d,stroke:#000,stroke-width:1px
    classDef paging fill:#ffd59e,stroke:#000,stroke-width:1px
    classDef timer fill:#e2baf6,stroke:#000,stroke-width:1px
    classDef core fill:#c0c0c0,stroke:#000,stroke-width:1px
    classDef external fill:#ffffff,stroke:#333,stroke-dasharray:5 5
```
