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
void setup() {
// put your setup code here, to run once:
// pinMode( led_pin ,OUTPUT );
Serial.begin(300);
vTaskDelay(1000 / portTICK_PERIOD_MS);
Serial.println("----FREE RTOS DEMO ----");
Serial.println("setup and loop task running on core ");
Serial.print(xPortGetCoreID());
Serial.print(" with priority ");
Serial.println(uxTaskPriorityGet(NULL));
//task to run forever
xTaskCreatePinnedToCore( //USE xTaskCreate() in vanilla FreeRTOS
startTask1, //Function to be called
"Task 1", //NAME of Task
1024, //Stack Size ( bytes in esp32 ,words in vanilla)
NULL, //Parameters to pass to function,
1, //Task priority ( 0 to configMAX_priorites(25 for esp32 ) -1 i.e 0 to 24)
&task_1, //parameters to pass to functions
app_cpu); //Run on One Core for demo purpose
xTaskCreatePinnedToCore( //USE xTaskCreate() in vanilla FreeRTOS
startTask2, //Function to be called
"Task 2", //NAME of Task
1024, //Stack Size ( bytes in esp32 ,words in vanilla)
NULL, //Parameters to pass to function,
2, //Task priority ( 0 to configMAX_priorites(25 for esp32 ) -1 i.e 0 to 24)
&task_2, //parameters to pass to functions
app_cpu); //Run on One Core for demo purpose
}
void loop() {
// put your main code here, to run repeatedly:
for( int i = 0 ; i < 3 ; i++ )
{
vTaskSuspend(task_2);
vTaskDelay(2000 / portTICK_PERIOD_MS);
vTaskResume(task_2);
vTaskDelay(2000 / portTICK_PERIOD_MS);
Problem :
when statement 1 is selected program run smoothly i.e task 2 keeps printing "*" continously after deletion of task 1,
but if statement 2 is selected program gets stuck .
whats happens if suspended task is deleted in free rtos?
The text was updated successfully, but these errors were encountered:
Board = ESP32
version = 1.0.6
CODE
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu = 0 ;
#else
static const BaseType_t app_cpu = 1;
#endif
//const char msg[] = "qwerty is aqsws"; //STATEMENT - 1
const char msg[] = "qwqwmqkqkw kkwmdkwdksd ksmdksmdks ksmdksmd"; //STATEMENT - 2
//static const int led_pin = 2;
//TAsk Handlers
static TaskHandle_t task_1 = NULL;
static TaskHandle_t task_2 = NULL;
void startTask1( void *parameters)
{
int msg_len = strlen(msg);
while(1)
{
Serial.println();
for(int i =0 ; i < msg_len ;i++)
{
Serial.print(msg[i]);
}
Serial.println();
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void startTask2( void *parameters)
{
while(1)
{
Serial.print('*');
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
void setup() {
// put your setup code here, to run once:
// pinMode( led_pin ,OUTPUT );
Serial.begin(300);
vTaskDelay(1000 / portTICK_PERIOD_MS);
Serial.println("----FREE RTOS DEMO ----");
Serial.println("setup and loop task running on core ");
Serial.print(xPortGetCoreID());
Serial.print(" with priority ");
Serial.println(uxTaskPriorityGet(NULL));
//task to run forever
xTaskCreatePinnedToCore( //USE xTaskCreate() in vanilla FreeRTOS
startTask1, //Function to be called
"Task 1", //NAME of Task
1024, //Stack Size ( bytes in esp32 ,words in vanilla)
NULL, //Parameters to pass to function,
1, //Task priority ( 0 to configMAX_priorites(25 for esp32 ) -1 i.e 0 to 24)
&task_1, //parameters to pass to functions
app_cpu); //Run on One Core for demo purpose
xTaskCreatePinnedToCore( //USE xTaskCreate() in vanilla FreeRTOS
startTask2, //Function to be called
"Task 2", //NAME of Task
1024, //Stack Size ( bytes in esp32 ,words in vanilla)
NULL, //Parameters to pass to function,
2, //Task priority ( 0 to configMAX_priorites(25 for esp32 ) -1 i.e 0 to 24)
&task_2, //parameters to pass to functions
app_cpu); //Run on One Core for demo purpose
}
void loop() {
// put your main code here, to run repeatedly:
for( int i = 0 ; i < 3 ; i++ )
{
vTaskSuspend(task_2);
vTaskDelay(2000 / portTICK_PERIOD_MS);
vTaskResume(task_2);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
if( task_1 != NULL ){
vTaskDelete(task_1);
task_1 =NULL;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Problem :
when statement 1 is selected program run smoothly i.e task 2 keeps printing "*" continously after deletion of task 1,
but if statement 2 is selected program gets stuck .
whats happens if suspended task is deleted in free rtos?
The text was updated successfully, but these errors were encountered: