What is an interrupt?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Operating Systems basics — a prerequisite for any developer role.
Answer
An interrupt is a signal to the processor from hardware or software indicating an event that requires immediate attention. Interrupts allow the OS to respond to events asynchronously without polling. How interrupts work: a device or condition raises an interrupt signal on the CPU's interrupt pin → CPU finishes the current instruction → saves current state (registers, PC) → looks up the Interrupt Vector Table (IVT) to find the Interrupt Service Routine (ISR) address → transfers control to the ISR → ISR handles the event → restores state → resumes original execution. Types of interrupts: (1) Hardware interrupts (external): keyboard keypress, mouse click, timer tick, disk I/O completion, network packet arrival — signals from I/O devices; (2) Software interrupts (traps/exceptions): triggered by executing special instructions — system calls (int 0x80, syscall instruction), division by zero, page fault, invalid memory access, overflow; (3) Timer interrupts: generated periodically by the timer chip — enables preemptive scheduling (time quantum expiration). Interrupt priority: multiple interrupts can occur simultaneously — handled by priority levels. Higher-priority interrupts can preempt lower-priority ISRs. Maskable vs non-maskable: maskable interrupts can be temporarily disabled (during critical sections); non-maskable interrupts (NMI) always handled (hardware failure, power failure). DMA (Direct Memory Access): devices transfer data to/from memory without CPU involvement, interrupt CPU only on completion — reduces CPU overhead for I/O.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Operating Systems project, I used this when...' immediately makes your answer more credible and memorable.