Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A user presses a key while a program is running. Describe how the interrupt is generated and how it is handled. The question is worth 5 marks.
The processor checks for interrupts at the end of each fetch-decode-execute cycle. If an interrupt has a higher priority than the task, it saves the state of the task (the register contents). It runs the interrupt service routine (ISR) for that interrupt, then restores the state and carries on. The highest priority interrupt is serviced first.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
A full answer. The keyboard sends an interrupt signal to the processor. At the end of the current fetch-decode-execute cycle, the processor checks for interrupts and checks the priority. It saves the state of the running program, the contents of its registers. It runs the interrupt service routine for the key press, which reads and stores the key. Then it restores the saved state and the program carries on from where it stopped.
Marking list.
Watch out. Keep the steps in order. Saving the state comes before the ISR, and restoring it comes after.
Log in to join the discussion.
Loading…