Task1 and Task2Task1 a priority of 2Task2 a priority of 1Task1 and Task2Task1 a priority of 2Task2 a priority of 1Task1 and Task2. Each function should be an infinite loop that prints "Task 1 is running" and "Task 2 is running" respectively, then calls vTaskDelay(1000 / portTICK_PERIOD_MS) to wait for 1 second.Use while(1) loops inside each task function to keep them running. Use printf to print messages and vTaskDelay to pause.
xTask1Handle and xTask2Handle. Also, create two variables task1Priority and task2Priority and set them to 2 and 1 respectively.Use TaskHandle_t to declare task handles. Use const UBaseType_t for priority variables.
xTaskCreate to create Task1 and Task2 with their respective priorities task1Priority and task2Priority. Pass the task handles xTask1Handle and xTask2Handle to store the created tasks.Use xTaskCreate with parameters: function name, task name string, stack size, parameters (NULL), priority, and task handle address.
vTaskStartScheduler() to start the FreeRTOS scheduler. Then print "Scheduler started" before starting. This will run the tasks with their assigned priorities.Call vTaskStartScheduler() after printing the message to begin running the tasks.
In FreeRTOS, what does a higher task priority number mean?
Which of the following is the correct way to assign a priority of 3 to a task in FreeRTOS using xTaskCreate?
void vTaskFunction(void *pvParameters) { /* Task code */ }
xTaskCreate(vTaskFunction, "Task1", 1000, NULL, ?, NULL);Given the following FreeRTOS code snippet, which task will run first?
void TaskA(void *pvParameters) { while(1) {} }
void TaskB(void *pvParameters) { while(1) {} }
xTaskCreate(TaskA, "A", 1000, NULL, 2, NULL);
xTaskCreate(TaskB, "B", 1000, NULL, 4, NULL);What is wrong with this FreeRTOS task creation code snippet?
void vTask(void *pvParameters) { /* code */ }
xTaskCreate(vTask, "Task", 1000, NULL, 5, NULL);
xTaskCreate(vTask, "Task", 1000, NULL, -1, NULL);You have three tasks with priorities 1, 3, and 3. How should you assign priorities to ensure the most important task runs first and the least important runs last?
Choose the best priority assignment:
Pass the test and this pattern moves unknown