# Linux Interrupt /Interrupt Service Routune (ISR) Hardware Interrupt Maskable Interrupt (multiplexing interrupts) non-maskable interrupt,NMI (e.g., watchdog ) Software Interrupt, e.g., int 0x80~system call [Interrupt, ISR, top half, bottom half and multiplexing](https://hackmd.io/@pingulinux/isr-interrupt-top-half) [入門級 Mouse Linux Kernel Driver](https://fred-zone.blogspot.com/2010/01/mouse-linux-kernel-driver.html) [How to Write Linux Mouse Drivers, by Alan Cox](https://www.linuxtoday.com/blog/linux-mouse-drivers/) [GPIO Linux Device Driver (GPIO Interrupt) – Linux Device Driver Tutorial Part 36 ](https://embetronicx.com/tutorials/linux/device-drivers/gpio-linux-device-driver-using-raspberry-pi/) [Using Kernel Timer In Linux Device Driver – Linux Device Driver Tutorial Part 26](https://embetronicx.com/tutorials/linux/device-drivers/using-kernel-timer-in-linux-device-driver/) **SLR:** Code executing from interrupt context **cannot** do the following: 1. Go to sleep or relinquish the processor 2. Acquire a mutex 3. Perform time-consuming tasks 4. Access user space virtual memory What if, I want to do a huge amount of work upon receiving interrupts? So it is a problem, right? If we take more time to process, this will happen. While the highest priority ISR is running, it doesn’t let other interrupts to run. Interrupts with the same type will be missed. To **eliminate** that problem, the processing of interrupts is split into two parts or halves: **Top halves** **Bottom halves** There are 4 bottom half mechanisms are available in Linux: 1. Workqueue~ Executed in a process context. 2. [Threaded IRQs](https://hackmd.io/@pingulinux/LinuxInterrupt) 3. Softirq (最要不要使用這個, 除非真的需要)~Executed in an atomic context. 4. Tasklets~Executed in an atomic context. :::success **Atomic context** is an execution state of the Linux kernel in which kernel code monopolizes a CPU core. In this state, the Linux kernel may only perform operations that cannot sleep, as otherwise a system hang or crash may occur. ::: :::success linux/interrupt.h struct softirq_action { void (*action)(struct softirq_action *); //softirq handler }; enum { HI_SOFTIRQ=0, TIMER_SOFTIRQ, NET_TX_SOFTIRQ, NET_RX_SOFTIRQ, BLOCK_SOFTIRQ, IRQ_POLL_SOFTIRQ, TASKLET_SOFTIRQ, SCHED_SOFTIRQ, HRTIMER_SOFTIRQ, RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ NR_SOFTIRQS }; **static struct softirq_action softirq_vec[NR_SOFTIRQS];** ::: :::info **有難度** [linux kernel的中断子系统之(八):softirq](https://www.wowotech.net/irq_subsystem/soft-irq.html) [Day 29:IRQ (Part 3) - 這是核心執行緒的味道!Threaded IRQ](https://ithelp.ithome.com.tw/articles/10253342) :::