This is a question about the stacks and interrupts.
Lets consider a program written in the C language where there is one thread and one interrupt.
1) The interrupt (sampleReady())
indicates to the program that a sample
is waiting on a peripheral.
2) The main function calls a subroutine Analyze()
to process each sample.
Of course when the main calls Analyze
, a context is created for Analyze()
on the stack A. It contains:
a) its parameters b) local variables c) return address d) base pointer
Then the interrupt happens. One saves the PC, probably several registers, Status register, ...
After, the ISR can execute.
Questions:
1) Which thread runs the ISR? Is it the same that runs main and Analyze()
?
2) On which stack is the context of the ISR pushed? Same stack as main and Analyze()
?
Also don't hesitate to correct any assumptions I made.