Which stack is used by Interrupt Handler - Linux
All interrupts are handled by kernel. That is done by interrupt handler written for that particular interrupt. For Interrupt handler there is IRQ stack. The setup of an interrupt handler’s stacks is configuration option. The size of the kernel stack might not always be enough for the kernel work and the space required by
IRQ processing routines. Hence 2 stack comes into picture.
- Hardware IRQ Stack.
- Software IRQ Stack.
In contrast to the regular kernel stack that is allocated per process, the two additional stacks are allocated per CPU. Whenever a hardware interrupt occurs (or a softIRQ is processed), the kernel needs to switch to
the appropriate stack.
Historically, interrupt handlers did not receive their own stacks. Instead, interrupt handlers would share the stack of the running process, they interrupted. The kernel stack is two pages in size; typically, that is 8KB on 32-bit architectures and 16KB on 64-bit architectures. Because in this setup interrupt handlers share the stack, they must be exceptionally frugal with what data they allocate there. Of course, the kernel stack is limited to begin with, so all kernel code should be cautious.
Interrupt Handler time accounting
Executing an hardware-interrupt handler would mean that the process is pre-empted.
However the pre-empted process is not suspended, it remains in the TASK_RUNNING state; it simply no longer uses the CPU (which will be busy executing the Interrupt Service Routine)
[1]
.
The time spent executing the ISR will count towards the interrupted process and hence the terminology that the ISR "steals" time from the process.
The following implementation of a simple kernel illustrates this in detail.
Related Topics
Mmap: Will the Mapped File Be Loaded into Memory Immediately
Is It Safe to Issue Blocking Write() Calls on the Same Tcp Socket from Multiple Threads
Creating a Raw Printer Queue in Cups (Host) and Adding Them Through Cups (Client)
Coreos - Get Docker Container Name by Pid
Run Docker in Ubuntu Live Disk
How to Implement a Practical Fiber Scheduler
Open O_Creat | O_Excl on Nfs in Linux
What Do the Characters in the Bash Environment Variable $- Mean
Is There Any Significant Difference Between Tcp_Cork and Tcp_Nodelay in This Use-Case
How to Get Notified for Ip Address Changes Automatically
Redirecting Man Page Output to File Results in Double Letters in Words
How to Delete Everything in a String After a Specific Character
Poorly-Balanced Socket Accepts with Linux 3.2 Kernel VS 2.6 Kernel
How to Check Whether the Processor Cache Has Been Flushed Recently