A great deal of the kernel consists of code that is invoked as the result of a interrupt or a trap.
While the words "interrupt" and "trap" are often used interchangeably in the context of operating systems, there is a distinct difference between the two.
An interrupt is a CPU event that is triggered by some external device.
A trap is a CPU event that is triggered by a program. Traps are sometimes called software interrupts. They can be deliberately triggered by a special instruction, or they may be triggered by an illegal instruction or an attempt to access a restricted resource.