Signals and interrupts a comparison

Vivek Maran picture Vivek Maran · Nov 12, 2012 · Viewed 34.3k times · Source

Based on various references, my subjective definition of signals in Linux is "The triggers that are used to notify the processes about an occurrence of a specific event.Event here may refer to a software exception.Additionally signals may also be used for IPC mechanisms." The questions I have are

  • I presume only exceptions (software interrupts) are notified via signals.What about the case of hardware interrupts.
  • What are the various sources of the signal? To me it looks like kernel is always the source of a signal.(except when used for IPC)
  • Difference between the signal handler and the ISR?.
  • Difference between signal blocking and interrupt masking?

Answer

ninjalj picture ninjalj · Nov 14, 2012

Interrupts can be viewed as a mean of communication between the CPU and the OS kernel. Signals can be viewed as a mean of communication between the OS kernel and OS processes.

Interrupts may be initiated by the CPU (exceptions - e.g.: divide by zero, page fault), devices (hardware interrupts - e.g: input available), or by a CPU instruction (traps - e.g: syscalls, breakpoints). They are eventually managed by the CPU, which "interrupts" the current task, and invokes an OS-kernel provided ISR/interrupt handler.

Signals may be initiated by the OS kernel (e.g: SIGFPE, SIGSEGV, SIGIO), or by a process(kill()). They are eventually managed by the OS kernel, which delivers them to the target thread/process, invoking either a generic action (ignore, terminate, terminate and dump core) or a process-provided signal handler.