As far as I know C compiler uses a stack structure in order to allocate local variables, function arguments, etc, when a function is called. But FreeRTOS bypass this mechanism and uses its own managed heap to allocate the call stack frame?
The question is: How exactly? Where do you instruct your compiler/linker in order to use your own memory management scheme for function call stack?
I looked at FreeRTOS source code, for the targets and compilers I know a little better (ARM and Microchip MCUs; GCC, Keil, IAR compilers), but can't find how this is done.
Thank you very much for your help.
Rather than diving into the source code, you can read about how the FreeRTOS works here: https://www.freertos.org/implementation/main.html
The compiler/linker know nothing about how the stack is managed by FreeRTOS. The kernel takes care of all the work. This is called Context Switching.
To summarize, when a task is being switched out, the kernel will copy all the required processor registers (i.e. the Context) into the Task Control Block (TCB). When the task is resumed, the registers are restored from the TCB and the task can continue as if nothing has happened.
The implementation differs for each architecture. You can check the AVR port, as it is relatively simple.