Interrupt


Mechanism

  1. Causes Process (进程) to temporarily suspend
  2. Save the state info of the process into the corresponding Process Control Block (PCB)
  3. Executes the Interrupt Handler
  4. When Interrupt Handler is done, the running Process (进程) is restarted and the state is restored from the PCB

Free the CPU, no more Polling

We don’t need to get CPU to keep Polling for response which may take a long time to produce. Instead, send a notification to the CPU via interrupt. Thus, CPU is able to do other stuff while waiting for a response

Better Security

Programs in User Space switching Privilege Level themselves is dangerous. With Software Interrupt, the CPU is preconfigured by Kernel with where in the kernel code to jump to

Generally can't be interrupted

Interrupts are allowed to run to completion without being interrupted by other sources. For example, if a keyboard’s interrupt is interrupted, we may lose the input from the keyboard

However, there are exceptions (This part I haven’t explored yet)

Busy State

As long as the Interrupt Handler is running, other interrupts may not be handled, and interrupts are generally not queued

But Interrupt Priorities exist in some systems to handle Simultaneous Interrupts

Tip

Interrupts should complete quickly to prevent the above problems

Trap Interrupt

Used to switch from User Mode to Kernel Mode

See Trap Interrupt (陷入) for more details

Software Interrupt


  • Known as upcalls, or Signal in Unix, or asynchronous events in Windows
  • Process (进程) being told when some event that deserves immediate attention has occurred, to virtualise some part of the kernel, so that applications can behave more like kernel, follow the Synchronous Sequential Circuit behaviour

Hardware interrupts (外中断)