mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-19 19:11:48 +02:00
Update ESP32 base load task to have more variety
This commit is contained in:
parent
eb4859c31d
commit
dea3d1307a
@ -12,32 +12,32 @@ esp_pm_lock_handle_t lightSleepLock;
|
|||||||
static bool pmLocksCreated = false;
|
static bool pmLocksCreated = false;
|
||||||
|
|
||||||
|
|
||||||
void stress_task0(void *pvParameters) {
|
void stress_task(void *pvParameters) {
|
||||||
// Register ourselves with the task watchdog
|
// Register with task watchdog
|
||||||
if (esp_task_wdt_add(NULL) != ESP_OK) {
|
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
|
||||||
Serial.println("Failed to add task 0 to TWDT");
|
|
||||||
}
|
|
||||||
while (1) {
|
|
||||||
volatile uint32_t x = 0;
|
|
||||||
for (uint32_t i = 0; i < 10000; i++) {
|
|
||||||
x += i;
|
|
||||||
}
|
|
||||||
esp_task_wdt_reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void stress_task1(void *pvParameters) {
|
// Variables for load generation
|
||||||
// Register ourselves with the task watchdog
|
|
||||||
if (esp_task_wdt_add(NULL) != ESP_OK) {
|
|
||||||
Serial.println("Failed to add task 0 to TWDT");
|
|
||||||
}
|
|
||||||
while (1) {
|
|
||||||
volatile uint32_t x = 0;
|
volatile uint32_t x = 0;
|
||||||
for (uint32_t i = 0; i < 10000; i++) {
|
TickType_t last_wake_time = xTaskGetTickCount();
|
||||||
x += i;
|
|
||||||
|
while (1) {
|
||||||
|
// Compute-intensive period
|
||||||
|
for (uint32_t i = 0; i < 10000; i++) {
|
||||||
|
x += i;
|
||||||
|
// Mix in some memory operations
|
||||||
|
if (i % 100 == 0) {
|
||||||
|
// Force cache misses occasionally
|
||||||
|
void* temp = malloc(32);
|
||||||
|
if (temp) {
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset watchdog
|
||||||
|
ESP_ERROR_CHECK(esp_task_wdt_reset());
|
||||||
|
|
||||||
}
|
}
|
||||||
esp_task_wdt_reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -113,8 +113,8 @@ void loop() {
|
|||||||
setupAndCleanupSerialPrint("Beginning stress phase\n");
|
setupAndCleanupSerialPrint("Beginning stress phase\n");
|
||||||
TaskHandle_t core0StressTask = NULL;
|
TaskHandle_t core0StressTask = NULL;
|
||||||
TaskHandle_t core1StressTask = NULL;
|
TaskHandle_t core1StressTask = NULL;
|
||||||
xTaskCreatePinnedToCore(stress_task0, "CPU0Stress", 4096, NULL, 1, &core0StressTask, 0);
|
xTaskCreatePinnedToCore(stress_task, "CPU0Stress", 4096, NULL, 1, &core0StressTask, 0);
|
||||||
xTaskCreatePinnedToCore(stress_task1, "CPU1Stress", 4096, NULL, 1, &core1StressTask, 1);
|
xTaskCreatePinnedToCore(stress_task, "CPU1Stress", 4096, NULL, 1, &core1StressTask, 1);
|
||||||
vTaskDelay(pdMS_TO_TICKS(cycleTime));
|
vTaskDelay(pdMS_TO_TICKS(cycleTime));
|
||||||
setupAndCleanupSerialPrint("Still alive after waiting cycleTime after setting up stress tasks...\n");
|
setupAndCleanupSerialPrint("Still alive after waiting cycleTime after setting up stress tasks...\n");
|
||||||
esp_task_wdt_delete(core0StressTask);
|
esp_task_wdt_delete(core0StressTask);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user