0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Smurf
  • 7
  • 4
  • What do you mean by ISR? Are you referring to operating system interrupt service routines? Or your own user-level routine? Which OS you are referring to here? – Milind Dumbare Mar 01 '15 at 13:53
  • ISR: Interrupt service routine The OS is micro C OS 2. Can you answer the question for 2 situations? 1) When the OS is micro C os 2 2) When there is no OS. Thank you, Frank – Smurf Mar 03 '15 at 12:11
  • I have no idea about the micro C OS 2. But in case of linux kernel the ISR is not part of either main() or analyze() thread, its a separate execution in Kernel . And the context of ISR is pushed on kernel stack. – Milind Dumbare Mar 03 '15 at 12:33
  • And if its user-level, one who calls sampleReady() is the thread where your ISR will run, right? – Milind Dumbare Mar 03 '15 at 12:54

0 Answers0