|
1 | 1 | # CPU Scheduling Algorithm Simulator |
2 | 2 |
|
3 | | -An interactive simulator for learning and testing various CPU scheduling algorithms, including First Come First Serve (FCFS), Round Robin(RR), Shortest Job First(SJF) and Shortest Remaining Time First(SRTF). This project provides a visual and dynamic way to understand scheduling algorithms, making it ideal for students and enthusiasts interested in operating systems. |
4 | | - |
5 | | -**[View the live application here](https://scheduling-algorithm-simulator.vercel.app/)**. |
6 | | - |
7 | | -## Table of Contents |
8 | | -- [Overview](#overview) |
9 | | -- [Features](#features) |
10 | | -- [Technologies Used](#technologies-used) |
11 | | -- [Project Structure](#project-structure) |
12 | | -- [Installation](#installation) |
13 | | -- [Usage](#usage) |
14 | | -- [Contributing](#contributing) |
15 | | -- [License](#license) |
16 | | - |
17 | | -## Overview |
18 | | - |
19 | | -This project is a web-based simulator for CPU scheduling algorithms. It allows users to input different processes with specific attributes (arrival time, burst time, etc.) and visualize how these processes are scheduled according to the chosen scheduling algorithm. |
| 3 | +Interactive CPU scheduling simulator with visual Gantt output, per-process metrics, and optional native C++ execution. |
20 | 4 |
|
21 | 5 | ## Features |
22 | 6 |
|
23 | | -- **Interactive Form**: Add and configure processes with attributes such as arrival time, burst time, and background color. |
24 | | -- **Scheduling Algorithms**: Currently supports FCFS (First Come First Serve), RR (Round Robin), SJF (Shortest Job First) and SRTF (Shortest Remaining Time First). |
25 | | -- **Real-Time Visualization**: Watch processes as they are scheduled and executed based on selected algorithms. |
26 | | -- **Dark Mode Support**: Uses a ThemeProvider for seamless switching between dark and light themes. |
| 7 | +- Algorithms: |
| 8 | + - FCFS (First Come First Serve) |
| 9 | + - SJF (Shortest Job First) |
| 10 | + - SRTF (Shortest Remaining Time First) |
| 11 | + - RR (Round Robin) |
| 12 | + - Priority Non-Preemptive |
| 13 | + - Priority Preemptive |
| 14 | +- Process fields: |
| 15 | + - Arrival Time |
| 16 | + - Burst Time |
| 17 | + - Priority |
| 18 | + - Color |
| 19 | +- Global scheduling controls: |
| 20 | + - Time Quantum (RR) |
| 21 | + - Context Switching Time (applied across algorithms) |
| 22 | +- Visual and metrics output: |
| 23 | + - Gantt chart with Idle and CS (context switch) blocks |
| 24 | + - Completion Time, Waiting Time, Turnaround Time |
| 25 | + - Average metrics, throughput, CPU utilization |
| 26 | +- Runtime strategy: |
| 27 | + - Native C++ addon used when available |
| 28 | + - TypeScript fallback when native addon is unavailable |
| 29 | + |
| 30 | +## Tech Stack |
| 31 | + |
| 32 | +- Next.js 14 |
| 33 | +- React + TypeScript |
| 34 | +- Tailwind CSS |
| 35 | +- React Hook Form + Zod |
| 36 | +- node-gyp + C++ (optional native path) |
| 37 | + |
| 38 | +## Project Structure |
| 39 | + |
| 40 | +```text |
| 41 | +app/ |
| 42 | + api/schedule/route.ts # Server-side scheduling endpoint (Node runtime) |
| 43 | +components/ |
| 44 | + MainForm.tsx # Inputs, run action, and results wiring |
| 45 | + GanttChart.tsx # Timeline visualization |
| 46 | + SummaryTable.tsx # CT / WT / TAT table |
| 47 | + SummaryStatistics.tsx # Averages and utilization |
| 48 | +cpp/ |
| 49 | + include/ # C++ headers |
| 50 | + src/ # C++ algorithm implementations + binding.cc |
| 51 | +lib/ |
| 52 | + scheduling-native.ts # Native loader with TS fallback |
| 53 | +binding.gyp # Native build config |
| 54 | +``` |
27 | 55 |
|
28 | | -## Technologies Used |
| 56 | +## Prerequisites |
29 | 57 |
|
30 | | -- **Next.js**: Frontend framework for React applications. |
31 | | -- **TypeScript**: Provides type safety and ensures code robustness. |
32 | | -- **Tailwind CSS**: Utility-first CSS framework for styling. |
33 | | -- **Zod**: For form validation schemas. |
34 | | -- **React Hook Form**: Handles form state and validation. |
35 | | -- **Custom Components**: Built-in components like `GradientPicker` for user-friendly UI interactions. |
| 58 | +- Node.js 20+ |
| 59 | +- npm |
| 60 | +- Python 3.10+ |
36 | 61 |
|
| 62 | +For native C++ build on Windows: |
| 63 | +- Visual Studio Build Tools 2022 (Desktop C++ workload) |
37 | 64 |
|
38 | 65 | ## Installation |
39 | 66 |
|
40 | | -To set up the project locally, ensure you have [Node.js](https://nodejs.org/en/download/) and [Yarn](https://classic.yarnpkg.com/en/docs/install/) or [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed. |
41 | | - |
42 | | -### Step 1: Clone the Repository |
43 | | - |
44 | 67 | ```bash |
45 | | -git clone https://github.com/kautilyadevaraj/SchedulingAlgorithmSimulator |
46 | | -cd scheduling-algorithm-simulator |
| 68 | +git clone https://github.com/kautilyadevaraj/SchedulingAlgorithmSimulator.git |
| 69 | +cd SchedulingAlgorithmSimulator |
| 70 | +npm install |
47 | 71 | ``` |
48 | 72 |
|
49 | | -### Step 2: Install Dependencies |
| 73 | +## Run Modes |
50 | 74 |
|
51 | | -Run the following command to install the necessary dependencies. |
52 | | -#### Using Yarn |
53 | | -```bash |
54 | | -yarn install |
55 | | -``` |
| 75 | +Standard mode (no native build required): |
56 | 76 |
|
57 | | -#### OR using npm |
58 | 77 | ```bash |
59 | | -npm install |
| 78 | +npm run dev |
60 | 79 | ``` |
61 | 80 |
|
62 | | -### Step 3: Environment Setup |
| 81 | +Native mode (build C++ first, then start): |
63 | 82 |
|
64 | | -No environment variables are required for this project in its current state. However, if you extend the project with a backend API or database, create a .env.local file in the root directory for environment variables. |
| 83 | +```bash |
| 84 | +npm run dev:native |
| 85 | +``` |
65 | 86 |
|
66 | | -### Step 4: Run the Development Server |
| 87 | +## Native Build Commands |
67 | 88 |
|
68 | | -Start the development server by running: |
69 | | -#### Using Yarn |
70 | 89 | ```bash |
71 | | -yarn dev |
| 90 | +npm run build-native |
| 91 | +npm run clean-native |
72 | 92 | ``` |
73 | 93 |
|
74 | | -#### OR using npm |
75 | | -```bash |
76 | | -npm run dev |
| 94 | +If native build succeeds, addon output is generated at: |
| 95 | + |
| 96 | +```text |
| 97 | +build/Release/scheduling_algorithms.node |
77 | 98 | ``` |
78 | | -This will start the Next.js development server at [http://localhost:3000](http://localhost:3000). You can view the project in your browser by navigating to this address. |
79 | 99 |
|
80 | | -## Step 5: Build for Production (Optional) |
| 100 | +## Production Build |
| 101 | + |
| 102 | +Standard production build: |
81 | 103 |
|
82 | | -If you want to build the project for production, run: |
83 | | -#### Using Yarn |
84 | 104 | ```bash |
85 | | -yarn build |
| 105 | +npm run build |
| 106 | +npm run start |
86 | 107 | ``` |
87 | 108 |
|
88 | | -#### OR using npm |
| 109 | +Native production build: |
| 110 | + |
89 | 111 | ```bash |
90 | | -npm run build |
| 112 | +npm run build:native |
| 113 | +npm run start |
91 | 114 | ``` |
92 | | -This will create an optimized production build in the .next folder. |
93 | 115 |
|
94 | | -## Usage |
| 116 | +## Troubleshooting |
95 | 117 |
|
96 | | -1. Add Processes: Use the form to add processes with specific arrival times, burst times, and custom background colors. |
97 | | -2. Select Algorithm: Choose a scheduling algorithm from the provided options (e.g., SRTF, FCFS). |
98 | | -3. Run Simulation: The simulator will display the scheduling results in a real-time animation. |
| 118 | +- Native addon missing warning: |
| 119 | + - App still runs using TypeScript fallback. |
| 120 | +- Windows node-gyp issues: |
| 121 | + - Ensure VS 2022 Build Tools are installed and complete. |
| 122 | + - Reopen terminal after installation. |
| 123 | + - Run `npm run clean-native` then `npm run build-native`. |
| 124 | +- Node 24 build requirement: |
| 125 | + - C++20 is required by Node headers; this repository is configured accordingly in `binding.gyp`. |
99 | 126 |
|
100 | 127 | ## Contributing |
101 | 128 |
|
102 | | -We welcome contributions! To contribute to this project, please follow these steps: |
103 | | - |
104 | 129 | 1. Fork the repository. |
105 | | -2. Create a new branch (git checkout -b feature-branch-name). |
106 | | -3. Make your changes. |
107 | | -4. Commit your changes (git commit -m 'Add some feature'). |
108 | | -5. Push to the branch (git push origin feature-branch-name). |
109 | | -6. Open a Pull Request. |
110 | | - |
111 | | -For major changes, please open an issue first to discuss what you would like to change. |
| 130 | +2. Create a branch. |
| 131 | +3. Commit focused changes. |
| 132 | +4. Open a pull request. |
112 | 133 |
|
113 | 134 | ## License |
114 | 135 |
|
115 | | -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 136 | +MIT. See `LICENSE`. |
0 commit comments