PIC32MZ
void vApplicationIdleHook(void) { // function exists but has nothing }
ISR stack ? not sure, but it is defined as: #define configISR_STACK_SIZE ( 512 )
21 words would be fine.. but mine fails with 256 words :\
For PIC32MZ I can see the port_asm.S code and it saves about 34 registers, 34*4=136bytes?
then I can see Idle task is doing some business management.. but..
I am not familiar with this processor, but with a quick search, it sounds like the processor itself doesn’t implement in hardware a separate stack, but seems to be an expectation that a multi-tasking operating system will provide hooks to allow ISRs to switch to an ISR stack if needed, and uses a separate set of registers (“Shadow registers”), minimizing the stack needed to save the basic register set.
That would mean that an ISR that doesn’t implement this, but does use appreciable stack could up the stack requirements for all tasks in the system.
The idle task actually does stuff, like freeing memory (from anything that had been created from dynamic memory allocation:
“The idle task is responsible for freeing memory allocated by the RTOS to tasks that have since been deleted. It is therefore important in applications that make use of the vTaskDelete() function to ensure the idle task is not starved of processing time. The idle task has no other active functions so can legitimately be starved of microcontroller time under all other conditions.“ (FreeRTOS idle task - FreeRTOS™)
But it’s unusual that it takes so much memory though.
“Swapped Out” Switched away from by the scheduler, which does this by saving all the processor context for the task onto its stack, and then storing the stack pointer into the TCB, and then getting the stack pointer for the next task to run, and restoring the context.
As to needing two stack pointers in the processor, that isn’t an absolute requirement. If the processor DOES have multiple stack pointers, and automatically switches, then the ISR automatically get their own stack (one they are setup).
Other processors only have a single stack pointer, and no software work around, will mean those processors need every task to have room for any ISR stack that might be needed.
Some, and I think the PIC32 falls into the category, are designed so that ISRs, with the proper preamble, can use just a minimal amount of the task stack, and then switch the stack pointer by code to use another one for the ISR. If the code wasn’t setup to do that, then they just run as processors without a separate stack and need more space on each tasks stack. This might be the case here, I don’t know if this processor has a common entry for ISRs, that then vectors out (in which case that common entry can have that code) or if every ISR needs some boiler plate to enable it.