Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I was reading about it and was thinking surely the queue first in first out system would make more sense than using a stack because the last instruction will become the first right because it’s lifo?
No. You have interrupts with same or different priorities. Interrupts with same priority will be handled in lifo order – but only one at a time. So that lifo queue would only ever have one entry. But with different priorities, a high priority interrupt can interrupt one with lower priority, so a stack is appropriate here.
The CPU does not store the instructions, it stores the instruction pointer, along with the state of the registers.
Think of putting a post-it in a book so you can get back to that page.