An Interrupt Service Routine (ISR) is a specialized software function that a processor executes immediately in response to a hardware or software interrupt. Its primary purpose is to handle time-critical events—such as a sensor reading being ready, a timer expiring, or a communication byte arriving—with minimal latency. The processor saves its current execution context, jumps to the ISR, executes it, and then restores the context to resume the main program. This mechanism is foundational for deterministic execution in embedded and robotic systems, allowing the system to react predictably to external stimuli.




