Hard interrupts:
1. Hard interrupts are generated by hardware, such as disks, network cards, keyboards, clocks, and so on. Each device or set of devices has its own IRQ (interrupt request). Based on IRQ,CPU, the corresponding request can be distributed to the corresponding hardware driver (note: The hardware driver is usually a subroutine in the kernel, not a separate process).
2. The driver that handles interrupts needs to be running on the CPU, so when the interrupt is generated, the CPU interrupts the currently running task to handle the interrupt. On a multi-core system, an interrupt usually interrupts only one CPU (there is also a special case where there is a hardware channel on the mainframe, which can handle multiple interrupts simultaneously without the support of the main CPU). )。
3. A hard interrupt can interrupt the CPU directly. It causes the associated code in the kernel to be triggered. For processes that take some time to process, the interrupt code itself can also be interrupted by other hard interrupts.
4. For clock interrupts, the kernel dispatch code suspends the currently running process, allowing other processes to run. It exists so that the dispatch code (or scheduler) can dispatch multiple tasks.
Soft Interrupt:
1. Soft interrupts are handled much like hard interrupts. However, they are generated only by the processes that are currently running.
2. In general, soft interrupts are some requests for I/O. These requests invoke a program in the kernel that can dispatch I/O occurrences. For some devices, I/O requests need to be processed immediately, and disk I/O requests can usually be queued and processed later. Depending on the I/O model, the process may be suspended until I/O completes, and the kernel scheduler chooses another process to run. I/O can be generated between processes and the scheduling process is usually the same as disk I/O.
3. Soft interrupts are only associated with the kernel. The kernel is primarily responsible for scheduling any other processes that need to be run. Some kernels allow some parts of the device driver to exist in the user space, and the kernel dispatches the process to run when needed.
4. Soft interrupts do not interrupt the CPU directly. Only the code (or process) that is currently running will produce a soft interrupt. Such interrupts are requests that require the kernel to do something (usually I/O) for a running process. There is a special soft interrupt that is the yield call, and its role is to request the kernel scheduler to see if there are some other processes that can run.
Question Answer:
1. Q: For soft interrupts, is the I/O operation done by the I/O device driver in the kernel?
A: For I/O requests, the kernel assigns this work to the appropriate kernel driver, which queues the I/O so that it can be processed later (usually disk I/O), or if it can be executed immediately. Typically, when a hard interrupt is responded to, the queue is handled by the driver. When an I/O request is completed, the next I/O request in the queue is sent to the device.
2. Q: Is the operating procedure for soft interrupts less than a hard interrupt? In other words, for a soft interrupt is the device driver in the kernel, the process, and for hard interrupts: hardware->cpu-> The device driver in the kernel?
A: Yes, a soft interrupt is less than a hard interrupt to send a signal to a hardware step. Processes that produce soft interrupts must be processes that are currently running, so they do not interrupt the CPU. But they interrupt the process of calling the code.
If the hardware needs the CPU to do something, then this hardware will interrupt the CPU that is currently running code. The CPU then puts the current state of the currently running process into the stack, so that it can then go back to running. This interrupt can stop a running process, can stop the kernel code that is processing another interrupt, or you can stop the idle process.
The difference between hard interrupts and soft interrupts!!!