How interrupts are being handled in Operating System ?

  • 0

    Brief explain role of CPU, Kernel, Process and memory etc how these interact when interrupt is there ?

  • 1

    As the name suggest it will interrupt any running process in the system. General overview of a process is a program under execution where it's loaded into memory and it's program instructions are being executed depending upon currently it's being scheduled and got access to CPU cycles.

    Now seeing in terms of Process when interrupt occurs, the current context of that process (also Program Counter) is saved and interrupt see it's interrupt vector table to lookup it's interrupt handler. Interrupt handler are there in kernel space. Hence once after process's context is saved interrupt handlers are executed. Once handler done execution, the interrupted process resumes from that Program Counter where it was being interrupted.

    Now, an interrupt allows the device to literally interrupt the processor to flag some information. For example, when a key is pressed, an interrupt is generated to deliver the key-press event to the operating system. Each device is assigned an interrupt by some combination of the operating system and BIOS.

    Devices are generally connected to an programmable interrupt controller (PIC), a separate chip that is part of the motherboard which buffers and communicates interrupt information to the main processor. Each device has a physical interrupt line between it an one of the PIC's provided by the system. When the device wants to interrupt, it will modify the voltage on this line.

    A very broad description of the PIC's role is that it receives this interrupt and converts it to a message for consumption by the main processor. While the exact procedure varies by architecture, the general principle is that the operating system has configured an interrupt descriptor table which pairs each of the possible interrupts with a code address to jump to when the interrupt is received.

    Writing this interrupt handler is the job of the device driver author in conjunction with the operating system.

Log in to reply

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