A task is an independent thread of execution managed by the RTOS, to the programmer it's a function with its own infinite loop that the kernel schedules concurrently with other tasks. Each task owns three things: its own stack, which holds its local variables, call frames, and its saved CPU context (registers) when it isn't running; a priority that tells the scheduler how urgent it is relative to other tasks; and a task control block (TCB), the kernel's per-task bookkeeping holding the stack pointer, current state, priority, and list links. The own-stack part is the key resource implication: N tasks means N stacks, each sized for its worst-case depth including interrupt nesting, which is a major RAM cost. A task is created with something like xTaskCreate (passing the function, stack size, parameter, and priority) and, importantly, it must never return, it loops forever or deletes itself, because returning off the end of a task function is undefined.
RTOS & Real-Time Concepts · Interview question
What is a task, and what does each one own?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Tasks & the Scheduler
A task is a function with its own stack, priority, and state; the scheduler runs the highest-priority ready task. The task lifecycle (Ready/Running/Blocked), the idle task, and vTaskDelay.