# anooragsingh07/cpu-schedsim--cpu-scheduling-simulator- architecture

> Architecture diagram of the GitHub repository anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-
- Repository: https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-

## Overview

##### Main Components
a. Process Generator – A module (or section of the code) that generates processes with randomized arrival times and CPU burst durations using the Exponential Distribution.
b. Scheduling Algorithm Modules – Although implemented in one file, conceptually separate the logic for the five scheduling algorithms:
- First-Come, First-Served (FCFS)
- Shortest-Job-First (Non-preemptive and Preemptive)
- Round-Robin (with adjustable time slice)
- Preemptive Priority Scheduling
c. Simulation Engine – The core simulation loop that handles the scheduling, context switching (fixed 14ms), tracking process execution, and timing.
d. Output/Analysis Component – This is the part of the simulator that computes process execution order, turnaround times, waiting times, and (in future versions) might provide a Gantt chart view for visualization.

##### Relationships & Data Flow
- The generated processes flow into the Simulation Engine.
- The Simulation Engine dynamically invokes one or more of the Scheduling Algorithm modules based on the selected scheduling policy.
- The Scheduling Algorithm modules determine which process should run next and communicate process state changes back to the Simulation Engine.
- Finally, the Simulation Engine aggregates the outcomes which are then either printed to the console or used for further analysis (e.g., calculating response times or waiting times).

##### Relevant Technologies and Frameworks
- The project is written in C++ using standard libraries.
- A possible dependency is the random number generation facilities (to simulate exponential distributions).
- Compiler and build tools (g++) are part of the development environment, though these are secondary for the high-level architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Generation Layer
    ProcessGenerator["Process Generator\n(Generates processes with randomized arrival times and CPU bursts)"]:::generation

    %% Execution and Analysis Layer
    SimulationEngine["Simulation Engine\n(Manages simulation loop, context switching, and process execution)"]:::engine
    OutputAnalysis["Output/Analysis\n(Computes turnaround times, waiting times, and aggregates results)"]:::output
    Configurations["Configurations\n(context switch: 14ms, adjustable time quantum, process count)"]:::note

    %% Scheduling Algorithms Subgraph
    subgraph "Scheduling Algorithms"
        direction TB
        FCFS["FCFS Scheduling"]:::scheduling
        SJF_NonPreemptive["SJF (Non-Preemptive)"]:::scheduling
        SJF_Preemptive["SJF (Preemptive)"]:::scheduling
        RoundRobin["Round Robin Scheduling"]:::scheduling
        PreemptivePriority["Preemptive Priority Scheduling"]:::scheduling
    end

    %% Relationships and Data Flow
    ProcessGenerator -->|"generates"| SimulationEngine
    SimulationEngine ---|"uses"| Configurations

    %% Simulation Engine calls scheduling algorithms
    SimulationEngine -->|"invokes"| FCFS
    SimulationEngine -->|"invokes"| SJF_NonPreemptive
    SimulationEngine -->|"invokes"| SJF_Preemptive
    SimulationEngine -->|"invokes"| RoundRobin
    SimulationEngine -->|"invokes"| PreemptivePriority

    %% Scheduling modules update simulation engine with process state changes
    FCFS -->|"updates"| SimulationEngine
    SJF_NonPreemptive -->|"updates"| SimulationEngine
    SJF_Preemptive -->|"updates"| SimulationEngine
    RoundRobin -->|"updates"| SimulationEngine
    PreemptivePriority -->|"updates"| SimulationEngine

    %% Simulation Engine aggregates and reports results
    SimulationEngine -->|"aggregates"| OutputAnalysis

    %% Project Documentation node
    Documentation["Project Documentation\n(README instructions and simulator details)"]:::doc

    %% Click Events
    click ProcessGenerator "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click SimulationEngine "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click FCFS "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click SJF_NonPreemptive "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click SJF_Preemptive "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click RoundRobin "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click PreemptivePriority "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click OutputAnalysis "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/process_scheduling_simulator.cpp"
    click Documentation "https://github.com/anooragsingh07/cpu-schedsim--cpu-scheduling-simulator-/blob/main/README.md"

    %% Styles
    classDef generation fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef engine fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef scheduling fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef output fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef doc fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef note fill:#e0e0e0,stroke:#333,stroke-width:1px,font-style:italic;
```
