Skip to content

Commit e34db93

Browse files
docs: update index.md — PI not PID, accurate Monitor/Actuator, platforms, no emojis
Made-with: Cursor
1 parent 81eece1 commit e34db93

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

docs/index.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ title: CPU Load Generator
55

66
# CPU Load Generator Project
77

8-
Welcome to the CPU Load Generator project — a Python-based tool that generates a fixed CPU load for a finite period using a PID regulator.
8+
Welcome to the CPU Load Generator project — a Python-based tool that generates a fixed CPU load for a finite or indefinite period on one or more CPU cores, using a **PI controller** (proportional–integral).
99

10-
![PID Regulator Block Diagram](https://gaetanocarlucci.altervista.org/wp-content/uploads/2024/07/pid-1.png)
10+
![PI Regulator Block Diagram](https://gaetanocarlucci.altervista.org/wp-content/uploads/2024/07/pid-1.png)
1111

12-
## 💡 Motivation
12+
## Motivation
1313

1414
This project is ideal for:
1515

@@ -19,28 +19,33 @@ This project is ideal for:
1919
- **Education & Training**
2020
- **Thermal & Power Analysis**
2121

22-
## 🧠 Architecture
22+
## Architecture
2323

2424
The system consists of:
2525

2626
- **CPU Target Load**
2727
- **Monitor Thread** for actual CPU usage measurement
28-
- **Controller Thread** (PID regulator)
28+
- **Controller Thread** (PI regulator)
2929
- **Actuator** adjusting sleep time for control
3030
- **Disturbances** (e.g., other processes)
3131

32-
## 🧪 Monitor Thread
32+
## Monitor Thread
3333

34-
Uses `psutil` to sample CPU load:
34+
Uses `psutil` to sample the **current process** CPU usage (per core when affinity is set):
3535
```python
36-
psutil.cpu_percent(interval)
36+
p = psutil.Process(os.getpid())
37+
sample = p.cpu_percent(sampling_interval)
3738
```
3839

39-
This blocks the thread for the sampling interval, ensuring timing consistency.
40+
The call blocks for the sampling interval, ensuring timing consistency.
4041

41-
## 🔧 Controller Thread (PID Regulator)
42+
## Controller Thread (PI Regulator)
4243

43-
Calculates a control signal to modulate load. If error is positive (load too low), it **reduces sleep** to increase load, and vice versa.
44+
Calculates a control signal (sleep time) to modulate load. If the error is positive (load too low), it **reduces sleep** to increase load, and vice versa. Tuned experimentally with `kp` and `ki`.
45+
46+
## Actuator
47+
48+
The actuator applies the controller output by alternating CPU-bound work and sleep. Less sleep ⇒ higher load.
4449

4550
```python
4651
def generate_load(self, sleep_time):
@@ -52,15 +57,15 @@ def generate_load(self, sleep_time):
5257
time.sleep(sleep_time)
5358
```
5459

55-
Tuned experimentally with `kp` and `ki`.
56-
57-
## 📊 Results
60+
## Results
5861

5962
The figure below shows the controller maintaining 50% CPU load.
6063

6164
![50% Target CPU Load](https://gaetanocarlucci.altervista.org/wp-content/uploads/2024/07/50-Target-Load.png)
6265

63-
## 📎 Resources
66+
**Supported platforms:** Linux, macOS, and Windows (see [README](https://github.com/GaetanoCarlucci/CPULoadGenerator#readme) for setup). Use `--plot` to show the load curve and save a PNG.
67+
68+
## Resources
6469

6570
- [Source Code on GitHub](https://github.com/GaetanoCarlucci/CPULoadGenerator)
6671
- [Original Article](https://gaetanocarlucci.altervista.org/cpu-load-generator-project/)

0 commit comments

Comments
 (0)