Page 1 of 1

can't get vTaskSuspend running

Posted: Tue Oct 25, 2016 11:14 am
by jumjum123
Trying to supend a task always results in panic. Any idea what I'm doing wrong ?

Code: Select all

TaskHandle_t handleTest = NULL;
static void test(void *data){
  vTaskDelay(10000 / portTICK_PERIOD_MS);
  ESP_LOGE("Test","will suspend now");
  vTaskSuspend(handleTest);
  ESP_LOGE("Test","just suspended");
}
int app_main(void)
{ system_init();
  xTaskCreatePinnedToCore(&test,"Test",2000,NULL,30,&handleTest,0);
  return 0;
}

Re: can't get vTaskSuspend running

Posted: Tue Oct 25, 2016 3:53 pm
by ESP_igrr
It panics because this function hasn't been tested:

https://github.com/espressif/esp-idf/bl ... ks.c#L1312

You can disable this behavior in menuconfig, in FreeRTOS options. Note that the function may still not work because it hasn't received test coverage yet.

Out of curiosity, what use case do you have for suspending a task?

Re: can't get vTaskSuspend running

Posted: Tue Oct 25, 2016 4:05 pm
by kolban
In deep reading of the RTOS docs, I read somewhere that a task, once created, is not meant to end. When I read that it sounded "daft" but that's what I remember reading.

That said, I have been able to end a task and the way to do that is to call

vTaskDelete(NULL);

as the last thing one does before ending the task. If one does NOT do that, then we do indeed crash when the task ends. Bottom line (for me) is to always end a FreeRTOS task with a vTaskDelete(NULL) because if you don't it crashes.

Try adding that to your code and see if that makes a change.

Re: can't get vTaskSuspend running

Posted: Tue Nov 01, 2016 11:32 pm
by jumjum123
Thanks for the feedback.
After changing the flag in menuconfig, I got suspend and resume running.
At least in my first Q&U testcase (Q&U is :? Quick&Ugly )