You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+51-2Lines changed: 51 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,55 @@ layout: default
3
3
title: CPU Load Generator
4
4
---
5
5
6
-
# CPU Load Generator
6
+
# CPU Load Generator Project
7
7
8
-
CPU load generator
8
+
Welcome to the CPU Load Generator project, a Python-based tool designed to generate a fixed CPU load for a finite period using a PID regulator. This tool is particularly useful for system administrators, developers, and researchers.
9
+
10
+
## Motivation
11
+
12
+
The CPU Load Generator serves multiple purposes:
13
+
14
+
-**Performance Testing**: Stress test applications and systems by generating a specific CPU load, helping identify performance bottlenecks and ensuring robustness under different load conditions.
15
+
-**Resource Allocation Optimization**: Simulate various load scenarios to optimize resource allocation and ensure critical applications receive the necessary computational power.
16
+
-**Benchmarking**: Provide a consistent and repeatable load for precise benchmarking, facilitating the comparison of different systems, CPUs, or configurations.
17
+
-**Education and Training**: Demonstrate the effects of CPU load on system performance, offering hands-on experience for students and trainees. University students can also understand the practical application of a PID regulator in a discrete environment.
18
+
-**Thermal and Power Consumption Analysis**: Study the thermal behavior and power consumption of CPUs under controlled load conditions.
19
+
20
+
## PID Regulator for Controlling CPU Load
21
+
22
+
The design of the CPU Load Generator involves several components:
23
+
24
+
-**CPU Target Load**: Desired percentage of CPU load on a specific core.
25
+
-**Monitor Thread**: Measures the percentage of actual CPU load on the specific core.
26
+
-**Error**: Percentage error of measured CPU load with respect to the target.
27
+
-**Controller Thread**: PID regulator with integral and proportional actions.
28
+
-**Controller Output**: The actuator signal that adjusts the CPU core load based on the measured error.
29
+
-**CPU Load**: The actual plant is the specific CPU core load.
30
+
-**Disturb**: Any other process that can disturb the CPU core load.
31
+
-**Process Variable**: The actual CPU load measured by the Monitor Thread after the control action.
32
+
33
+
### Monitor Thread
34
+
35
+
The Monitor Thread samples the CPU load at regular intervals, filters the measurements with a first-order filter, and logs various parameters over time. The value measured by the Monitor Thread is calculated using the `psutil` method `cpu_percent(interval)`, which calculates the CPU usage during the specified interval. The call to `cpu_percent` blocks the thread for the duration of the interval, ensuring that the loop naturally waits for the specified sampling time before proceeding to the next iteration. In this case, `psutil.Process` is used, meaning that the method measures the CPU usage generated by this particular process.
36
+
37
+
### Controller Thread
38
+
39
+
The Controller Thread compares the CPU load measured by the Monitor Thread and the target CPU load (set point). Based on the difference between them (tracking error), the PID regulator computes the control signal and sends it to the actuation device, which in turn drives the plant to the desired process value (set point).
40
+
41
+
When the error is fed to the PID regulator, it computes the:
42
+
43
+
-**P** (Proportional)
44
+
-**I** (Integral)
45
+
-**D** (Derivative)
46
+
47
+
contributions of this error signal with respect to time. In this project, the derivative contribution is not used. The proportional and integral components are weighted by coefficients and then summed up. The output of this operation is the actuator signal, which in our case is the sleep time used in the actuator function that generates CPU load.
0 commit comments