From 154ed66174af025f8d16e969312d66059e029d8d Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Mon, 9 Dec 2019 22:21:01 +0100 Subject: [PATCH] Pin Tasks to cores --- include/coreids.h | 5 +++++ src/UpdateServer.cpp | 7 +++++-- src/WebServer.cpp | 7 +++++-- src/main.cpp | 5 +++-- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 include/coreids.h diff --git a/include/coreids.h b/include/coreids.h new file mode 100644 index 0000000..60b78a5 --- /dev/null +++ b/include/coreids.h @@ -0,0 +1,5 @@ +#pragma once + +#define CORE_ID_LED 1 +#define CORE_ID_WEBSERVER 0 +#define CORE_ID_UPDATESERVER 0 diff --git a/src/UpdateServer.cpp b/src/UpdateServer.cpp index dd6c2a1..5edf711 100644 --- a/src/UpdateServer.cpp +++ b/src/UpdateServer.cpp @@ -6,19 +6,22 @@ #include "UpdateServer.h" +#include "coreids.h" + UpdateServer::UpdateServer(const std::string &pw) : m_cr(pw) {} void UpdateServer::start(void) { - xTaskCreate( + xTaskCreatePinnedToCore( updateTask, /* Task function. */ "Update Task", /* name of task. */ 10000, /* Stack size of task */ this, /* parameter of the task */ 2, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_UPDATESERVER); } static void sendMessage(WiFiClient *client, bool success, const char *message) diff --git a/src/WebServer.cpp b/src/WebServer.cpp index fed5684..1f39968 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -10,6 +10,8 @@ #include "Fader.h" #include "Animation/AnimationController.h" +#include "coreids.h" + WebServer::WebServer(void) : m_cr(Config::instance().getCRPassword()), m_fader(NULL) { @@ -274,13 +276,14 @@ void WebServer::serverTask(void *arg) bool WebServer::start(void) { - xTaskCreate( + xTaskCreatePinnedToCore( WebServer::serverTask, /* Task function. */ "HTTP Server Task", /* name of task. */ 6144, /* Stack size of task */ NULL, /* parameter of the task */ 1, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_WEBSERVER); return true; } diff --git a/src/main.cpp b/src/main.cpp index 9c9410a..39c5070 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -221,13 +221,14 @@ void setup() animController.changeAnimation(std::unique_ptr(new ConnectingAnimation(&ledFader)), false); - xTaskCreate( + xTaskCreatePinnedToCore( ledTask, /* Task function. */ "LED Task", /* name of task. */ 10000, /* Stack size of task */ NULL, /* parameter of the task */ 3, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_LED); // Connect the WiFi network (or start an AP if that doesn't work) for (auto &net : Config::instance().getWLANList())