Skip to content

Commit 20893b5

Browse files
committed
yml update
1 parent 4e662a3 commit 20893b5

File tree

4 files changed

+208
-36
lines changed

4 files changed

+208
-36
lines changed

.github/ctest.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ entered as 2-4 means Round Robin with q=4. Also, policy 8-1 means Aging with q=1
129129
2- Arrival Time\
130130
3- Priority
131131
- Processes are assumed to be sorted based on the arrival time. If two processes have the same arrival time, then the one with the lower priority is assumed to arrive first.
132-
> Check the attached [testcases](https://github.com/yousefkotp/CPU-Scheduling-Algorithms/tree/main/testcases) for more details.
132+
133133

134134

135135

docs/documentation.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# CPU Scheduling Algorithms Project Documentation
2+
3+
## Table of Contents
4+
5+
- [Introduction](#introduction)
6+
- [Implemented Algorithms](#implemented-algorithms)
7+
- [Project Structure](#project-structure)
8+
- [Installation](#installation)
9+
- [Input Format](#input-format)
10+
- [Usage](#usage)
11+
- [Testing](#testing)
12+
- [Algorithm Details](#algorithm-details)
13+
- [Extending the Project](#extending-the-project)
14+
- [References](#references)
15+
16+
---
17+
18+
## Introduction
19+
20+
This project implements various CPU scheduling algorithms in C++. It is designed to simulate and analyze the behavior of different scheduling strategies, providing both trace and statistical outputs. The project is suitable for educational purposes, operating systems coursework, and performance analysis.
21+
22+
---
23+
24+
## Implemented Algorithms
25+
26+
1. **FCFS (First Come First Serve)**
27+
2. **RR (Round Robin)**
28+
3. **SPN (Shortest Process Next)**
29+
4. **SRT (Shortest Remaining Time)**
30+
5. **HRRN (Highest Response Ratio Next)**
31+
6. **FB-1 (Feedback, all queues q=1)**
32+
7. **FB-2i (Feedback, q=2^i)**
33+
8. **Aging**
34+
35+
---
36+
37+
## Project Structure
38+
39+
```
40+
CPU-Scheduling-Algorithms-main/
41+
├── src/ # Source code for algorithms and main program
42+
├── include/ # Header files
43+
├── test/ # Unit tests (Google Test)
44+
├── docs/ # Documentation
45+
├── makefile # Build instructions
46+
├── README.md # Project overview and quick start
47+
└── run.sh # Shell script to build and run the project
48+
```
49+
50+
---
51+
52+
## Installation
53+
54+
1. **Clone the repository:**
55+
```sh
56+
git clone <repository-url>
57+
cd CPU-Scheduling-Algorithms-main
58+
```
59+
60+
2. **Install dependencies:**
61+
```sh
62+
sudo apt-get update
63+
sudo apt-get install -y g++ make libgtest-dev cmake
64+
```
65+
66+
3. **Build the project:**
67+
```sh
68+
make
69+
```
70+
71+
---
72+
73+
## Input Format
74+
75+
- **Line 1:** `"trace"` or `"stats"` (output mode)
76+
- **Line 2:** Comma-separated list of scheduling policies and parameters (e.g., `1,2-4,8-1`)
77+
- **Line 3:** Integer specifying the last instant for simulation
78+
- **Line 4:** Integer specifying the number of processes
79+
- **Line 5+:** Process descriptions (one per line)
80+
81+
### Process Description
82+
83+
- **Algorithms 1-7:**
84+
```
85+
<ProcessName>,<ArrivalTime>,<ServiceTime>
86+
```
87+
- **Algorithm 8 (Aging):**
88+
```
89+
<ProcessName>,<ArrivalTime>,<Priority>
90+
```
91+
92+
**Note:**
93+
Processes must be sorted by arrival time. If two processes have the same arrival time, the one with the lower priority arrives first.
94+
95+
---
96+
97+
## Usage
98+
99+
1. **Compile the project:**
100+
```sh
101+
make
102+
```
103+
104+
2. **Run the main executable:**
105+
```sh
106+
./main < input.txt
107+
```
108+
109+
Replace `input.txt` with your input file following the [Input Format](#input-format).
110+
111+
---
112+
113+
## Testing
114+
115+
Unit tests are provided using Google Test.
116+
117+
- **Build and run tests:**
118+
```sh
119+
make test
120+
./test/hello_gtest
121+
```
122+
123+
- **Automated testing:**
124+
GitHub Actions is configured to run tests on every push and pull request.
125+
126+
---
127+
128+
## Algorithm Details
129+
130+
### 1. FCFS (First Come First Serve)
131+
- Non-preemptive.
132+
- Processes are executed in the order they arrive.
133+
134+
### 2. RR (Round Robin)
135+
- Preemptive.
136+
- Each process gets a fixed time quantum in a cyclic order.
137+
138+
### 3. SPN (Shortest Process Next)
139+
- Non-preemptive.
140+
- Selects the process with the shortest service time.
141+
142+
### 4. SRT (Shortest Remaining Time)
143+
- Preemptive version of SPN.
144+
- Always runs the process with the shortest remaining time.
145+
146+
### 5. HRRN (Highest Response Ratio Next)
147+
- Non-preemptive.
148+
- Chooses the process with the highest response ratio.
149+
150+
### 6. FB-1 (Feedback, q=1)
151+
- Preemptive.
152+
- Multiple queues, all with quantum 1.
153+
154+
### 7. FB-2i (Feedback, q=2^i)
155+
- Preemptive.
156+
- Multiple queues, quantum doubles at each lower priority.
157+
158+
### 8. Aging
159+
- Preemptive.
160+
- Priorities of waiting processes increase over time to prevent starvation.
161+
162+
---
163+
164+
## Extending the Project
165+
166+
- Add new scheduling algorithms by creating new source files in `src/` and updating the main driver.
167+
- Add new tests in `test/` using Google Test.
168+
- Update the makefile as needed.
169+
170+
---
171+
172+
## References
173+
174+
- [Operating System Concepts by Silberschatz, Galvin, Gagne](https://www.os-book.com/)
175+
- [Wikipedia: Scheduling (computing)](https://en.wikipedia.org/wiki/Scheduling_(computing))
176+
-

run.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Installing dependencies..."
6+
sudo apt-get update
7+
sudo apt-get install -y g++ make libgtest-dev cmake
8+
9+
echo "Building Google Test (if needed)..."
10+
cd /usr/src/gtest
11+
sudo cmake .
12+
sudo make
13+
sudo cp *.a /usr/lib
14+
cd -
15+
16+
echo "Building project..."
17+
make
18+
19+
echo "Running main executable..."
20+
if [ -f "./main" ]; then
21+
./main
22+
else
23+
echo "No main executable found. Please check your makefile."
24+
fi
25+
26+
echo "Running tests (if available)..."
27+
if [ -f "./test/hello_gtest" ]; then
28+
./test/hello_gtest
29+
else
30+
echo "No test executable found. Skipping tests."
31+
fi

0 commit comments

Comments
 (0)