ACBDBAEFBFAGEFASuppose the computer on which this program is running has 4 pages of physical memory.
A | C | B | D | B | A | E | F | B | F | A | G | E | F | A | |
1 | A | + | + | + | |||||||||||
2 | C | E | G | ||||||||||||
3 | B | + | + | E | |||||||||||
4 | D | F | + | + |
A | C | B | D | B | A | E | F | B | F | A | G | E | F | A | |
1 | A | + | + | + | |||||||||||
2 | C | E | + | ||||||||||||
3 | B | + | + | G | |||||||||||
4 | D | F | + | + |
A | C | B | D | B | A | E | F | B | F | A | G | E | F | A | |
1 | A1 | 1 | 1 | 1 | 1 | +1 | E1 | 1 | 1 | 1 | 1 | 0 | +1 | 1 | 1 |
2 | C1 | 1 | 1 | 1 | 1 | 0 | F1 | 1 | +1 | 1 | 0 | 0 | +1 | 1 | |
3 | B1 | 1 | +1 | 1 | 0 | 0 | +1 | 1 | 0 | G1 | 1 | 1 | 1 | ||
4 | D1 | 1 | 1 | 0 | 0 | 0 | 0 | A1 | 1 | 1 | 1 | +1 |
Solution TBD.
First, the hardware switches the machine to supervisor mode and causes control to transfer to a routine at a pre-specified address. The operating system has already loaded that address with a pointer to a function that handles the interrupt. The function starts by saving all registers, possibly setting the allowed interrupts to a level that guarantees correct execution of the operating system, and then executes the code to serve the interrupt. When the operating system is done, it restores the registers again and calls the "iret" to return to the user program that was running when the interrupt occurred. If there is no runnable program, the operating system jumps to the idle loop and waits for an interrupt. Finally, if the interrupt occurred while the operating system was running, then the OS simply restores the registers and jumps to the instruction following the one at which the interrupt occurred.