Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A processor is running a spreadsheet. At the end of a fetch-decode-execute cycle, three interrupts are waiting. A larger number means a higher priority.
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.
Step 1. Sort by priority. The division by zero has priority , so it is in position 1. The key press has priority , position 2. The printer has priority , position 3.
Step 2. Before the first routine. The processor saves the state of the spreadsheet: the contents of its registers. After the routines, it restores the state, so the spreadsheet carries on from where it stopped.
Answer: (a) division by zero, key press, printer. (b) It saves the state of the task, so that it can restore it afterwards.
Watch out. The division by zero arrived last but goes first. Priority, not arrival time, decides the order. Arrival time decides only between equal priorities.
Log in to join the discussion.
Loading…