prevent double call of: xTaskCreatePinnedToCore #7758
Unanswered
rubenfrolic
asked this question in
Q&A
Replies: 2 comments
-
Yes, it will create another thread running the task.
Haven't done this yet, but as I understand it there are multiple options:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
You could also just check the state of the task by defining the task handle globally... TaskHandle_t taskHandleMyTask = NULL; void taskMyTask(void *params) {
} void runMyTask() {
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In an application playing some LED animations on the second core in parallel with the rest of the application. I'm doing this by creating a task using
xTaskCreatePinnedToCore
, this task plays the animation, and when finished the tasks deletes it self:vTaskDelete(NULL)
and then the esp will be put into deepsleep.It might happen that the main application will try to start an animation, while the other one is still playing. This results in
xTaskCreatePinnedToCore
being called, while the task is still running. I'd like to prevent this by checking the state of the task before I create it again.conceptually I wanted to do something like this:
This unfortunately is not working and reboots the module if there's no task being created yet:
assert failed: eTaskGetState tasks.c:1609 (pxTCB)
I basically have two questions:
Is there any harm in calling
xTaskCreatePinnedToCore
while the task is already running?Is there another way to check if a task is already running without getting into the problem above?
Beta Was this translation helpful? Give feedback.
All reactions