Explain how to create and manage tasks in FreeRTOS.
Answer
FreeRTOS is a popular open-source RTOS for embedded systems. Task creation: xTaskCreate(taskFunction, "name", stackSize, parameters, priority, &taskHandle); Task function is infinite loop with vTaskDelay() or blocking calls. Stack size in words (not bytes on some ports). Priority: 0 (lowest) to configMAX_PRIORITIES-1. Task management functions: vTaskDelete(handle) - remove task. vTaskSuspend(handle), vTaskResume(handle) - pause/resume. vTaskPrioritySet(handle, priority) - change priority. vTaskDelay(ticks), vTaskDelayUntil(&lastWake, period) - timing. uxTaskPriorityGet(handle) - query priority. Best practices: Keep tasks simple and single-purpose. Use appropriate stack sizes (check with uxTaskGetStackHighWaterMark). Avoid unbounded priority inversion. Use idle task hook for background work.
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.