Interrupts
Interrupts
Interrupts
What is an interrupt?
An interrupt is a signal for the CPU to stop what it is currently doing and do something else as a higher priority
The CPU is in a continuous loop of carrying out the fetch-decode-execute cycle, however there are occasions when this needs to be interrupted
How is an interrupt generated?
An interrupt can be generated by hardware and software:
Hardware - this is caused by a hardware device such as a hardware failure
Software - this occurs when an application stops or requests services from the OS
Interrupts are added to an area called the interrupt service routine
The interrupt service routine holds instructions that will need to be fetched, decoded and executed to complete the commands of the interrupt
The contents of the registers within the CPU cannot be lost by an interrupt, so contents are copied to a reserved area in RAM called a stack
Contents are added to the top of the stack, which will save them for later retrieval when the interrupt is complete
The interrupt will be executed instead of the original instructions
What are examples of hardware interrupts?
Hardware
power button may have been pressed
moving the mouse
clicking an icon to open a new program
keyboard presses e.g. ctrl, alt, delete
What are examples of software interrupts?
Software
a program is not responding
division by zero
two processes trying to access the same memory location