What is interrupt? How does interrupt work?


  • 1
    D

    Very basic but important questions.

    Reference answer: https://en.wikipedia.org/wiki/Interrupt


  • 7
    F

    Basically an interrupt is a signal to notify kernel(processor) that something needs to be handled as soon as possible. It's called interrupt because kernel(processor) may suspend what it is running to handle the interrupt event(by calling ISR) and then resume its execution.

    There are two types of interrupts: hardware interrupt(which caused by external device, like keyboard, mouse, disk, etc) and software interrupt(which caused by program, like system call, divide-by-zero)


  • 1
    A

    How does interrupt work?
    When you press or release a key, that event is signalled up the keyboard cable to raise a hardware interrupt. It's the operating system's job to watch for such interrupts. For each possible kind of interrupt, there will be an interrupt handler, a part of the operating system that stashes away any data associated with them (like your keypress/keyrelease value) until it can be processed. What the interrupt handler for your keyboard actually does is post the key value into a system area near the bottom of memory. There, it will be available for inspection when the operating system passes control to whichever program is currently supposed to be reading from the keyboard.
    Every kind of interrupt has an associated priority level. Lower-priority interrupts (like keyboard events) have to wait on higher-priority interrupts (like clock ticks or disk events). Unix is designed to give high priority to the kinds of events that need to be processed rapidly in order to keep the machine's response smooth.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.