Why is there a need for a separate task stack in an RTOS?

So guys we know that In an RTOS (Real-Time Operating System), the Task Control Block (TCB) holds information for task management. But doesn't the TCB already include all the data needed for context switching, like register values? Why is there a separate task stack then? @Middleware & OS
3 Replies
Nehal
Nehal7mo ago
If I understood your question correctly. The information hold by TCB is for how the API will work like the priority, core etc, its internal to the OS and the stack size we provide it if for the work (calling functions, data and memory manipulation etc) we want to do in that particular task.
Marvee Amasi
Marvee Amasi7mo ago
@Nehal , That makes sense. Does the TCB itself store any register values, or are those saved directly on the task stack during context switching?
Nehal
Nehal7mo ago
TCB along with other information stores stack pointer to resume from it left. Apart from it the stack we provide holds the current state of task and other information in registers are pushed into this stack regarding context switching. You can say that TCB organizes and manages the tasks, the actual register values and the runtime stack operations (like function calls and local data) are handled on the separate task stack.
Want results from more Discord servers?
Add your server