<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Debajyoti Maitra on Medium]]></title>
        <description><![CDATA[Stories by Debajyoti Maitra on Medium]]></description>
        <link>https://medium.com/@er.dmaitra?source=rss-f5b78d2fb627------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qAd6kBjmZkHVMKrn.jpg</url>
            <title>Stories by Debajyoti Maitra on Medium</title>
            <link>https://medium.com/@er.dmaitra?source=rss-f5b78d2fb627------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 12:53:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@er.dmaitra/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[All about Interrupts: IRQ, IVT, ISR]]></title>
            <link>https://medium.com/@er.dmaitra/irq-ivt-isr-0f9e02d6c510?source=rss-f5b78d2fb627------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f9e02d6c510</guid>
            <dc:creator><![CDATA[Debajyoti Maitra]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 08:05:00 GMT</pubDate>
            <atom:updated>2026-11-12T08:12:53.970Z</atom:updated>
            <content:encoded><![CDATA[<p>Core Concepts</p><p><strong>IRQ (Interrupt Request):</strong></p><ul><li>A hardware line or vector number (often designated by the <a href="https://www.lenovo.com/us/en/glossary/interrupt/">Programmable Interrupt Controller</a>) asserted by a peripheral device.</li><li>It tells the CPU, <em>“Stop what you are doing; I have urgent data or status for you.”</em> (e.g., a keystroke was pressed or a network packet arrived). [<a href="https://www.youtube.com/watch?v=7Z-fVmDPtj4">1</a>, <a href="https://www.geeksforgeeks.org/operating-systems/interrupts/">2</a>, <a href="https://www.youtube.com/watch?v=8WfJ0IXL0v0">3</a>, <a href="https://www.lenovo.com/us/en/glossary/interrupt/">4</a>]</li></ul><p><strong>IVT (Interrupt Vector Table):</strong></p><ul><li>An array or memory-mapped data structure (sometimes called an IDT — Interrupt Descriptor Table in modern x86/ARM systems) stored in low memory.</li><li>It acts as a phonebook: the CPU takes the incoming IRQ/vector number, uses it as an index into the IVT, and retrieves the exact memory address (segment and offset) where the response code lives. [<a href="https://medium.com/@vinita.palaniveloo/interrupt-service-routine-eb38e5dd5058">1</a>, <a href="https://www.youtube.com/watch?v=A5yAyaJGNzU">2</a>, <a href="https://www.thejat.in/learn/interrupts-idt-isr-and-irq">3</a>, <a href="https://www.youtube.com/watch?v=8WfJ0IXL0v0">4</a>, <a href="https://www.studocu.com/in/messages/question/7194252/what-are-peripheral-interrupts-ivt-and-isr">5</a>, <a href="https://www.youtube.com/watch?v=7Z-fVmDPtj4">6</a>]</li></ul><p><strong>ISR (Interrupt Service Routine):</strong></p><ul><li>Also called an <em>interrupt handler</em>, this is the actual block of code (usually part of a device driver) that the CPU jumps to.</li><li>It acknowledges the device, reads or writes data, clears the interrupt condition, and then executes an iret (interrupt return) instruction to restore the CPU registers and resume the interrupted background program. [<a href="https://www.youtube.com/watch?v=8WfJ0IXL0v0">1</a>, <a href="https://medium.com/@vinita.palaniveloo/interrupt-service-routine-eb38e5dd5058">2</a>, <a href="https://www.youtube.com/watch?v=7Z-fVmDPtj4">3</a>, <a href="https://www.thejat.in/learn/interrupts-idt-isr-and-irq">4</a>]</li></ul><h3><strong>How They Work Together</strong></h3><ol><li><strong>Trigger:</strong> A peripheral device raises an <strong>IRQ</strong> to get the CPU’s attention.</li><li><strong>Lookup:</strong> The CPU pauses its current task, saves its state to the stack, and uses the IRQ number to look up the entry in the <strong>IVT</strong>.</li><li><strong>Execution:</strong> The address from the IVT points the CPU directly to the <strong>ISR</strong>, which runs to fix or acknowledge the event before handing control back to the main program. [<a href="https://www.youtube.com/watch?v=st40aIC1Szk&amp;t=23">1</a>, <a href="https://www.lenovo.com/us/en/glossary/interrupt/">2</a>, <a href="https://www.youtube.com/watch?v=8WfJ0IXL0v0">3</a>, <a href="https://www.thejat.in/learn/interrupts-idt-isr-and-irq">4</a>, <a href="https://www.studocu.com/in/messages/question/7194252/what-are-peripheral-interrupts-ivt-and-isr">5</a>]</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qC92m9a_jaVmhm_CyLX_zA.png" /><figcaption>IRQ vs IVT vs ISR</figcaption></figure><p>An Interrupt Service Routine (ISR) always runs to completion before the operating system scheduler switches to any normal user or kernel process, regardless of how high that process’s priority is.</p><h3><strong>Why the ISR Always Finishes First</strong></h3><p>• Interrupt Context vs. Process Context: An ISR executes in a special interrupt context, not a process context. It does not have a process control block (PCB) or task structure of its own, which means the OS scheduler cannot pause, save, and resume it like a regular thread.</p><p>• Hardware State &amp; Masking: While an ISR is running, the CPU often has the same or lower-priority hardware interrupts disabled (masked) to prevent system instability. Leaving an ISR half-finished would leave hardware registers unacknowledged and interrupt lines blocked.</p><ul><li>No Blocking Allowed: Because the scheduler cannot switch away from an ISR, an ISR is strictly forbidden from calling functions that might sleep, block, or yield the CPU.</li></ul><h3><strong>Step-by-Step Execution Flow</strong></h3><p>1. ISR Runs: A hardware interrupt pauses the currently running task (let’s call it Low-Priority Process A) and starts the ISR.</p><p>2. Process Wakeup: Inside the ISR, the code places High-Priority Process B onto the OS ready queue and sets a system flag indicating a reschedule is needed (e.g., TIF_NEED_RESCHED in Linux).</p><p>3. ISR Completes: The ISR finishes its critical hardware work, clears the interrupt flag, and executes an interrupt-return instruction (iret or eret).</p><p>4. Scheduler Intercepts: Just before returning control back to Process A, the kernel checks the reschedule flag.</p><p>5. Context Switch Occurs: Seeing that High-Priority Process B is now ready and outranks Process A, the scheduler performs a context switch to Process B instead of resuming Process A.</p><h3><strong>The Only Exception: Nested Hardware Interrupts</strong></h3><p>• Higher-Priority Hardware IRQ: An ISR can only be paused mid-execution by another hardware interrupt that has a strictly higher hardware priority (if interrupt nesting is enabled).</p><p>• Immediate Return: Even in that case, the new higher-priority ISR runs to completion and immediately returns back to finish the first ISR — never to a scheduled OS process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f9e02d6c510" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MSI vs MSI-X on x86 /AArch64]]></title>
            <link>https://medium.com/@er.dmaitra/msi-vs-msi-x-on-x86-aarch64-9406f01942c1?source=rss-f5b78d2fb627------2</link>
            <guid isPermaLink="false">https://medium.com/p/9406f01942c1</guid>
            <category><![CDATA[lapic]]></category>
            <category><![CDATA[x86]]></category>
            <category><![CDATA[mi]]></category>
            <category><![CDATA[what-is-pcie]]></category>
            <category><![CDATA[msix]]></category>
            <dc:creator><![CDATA[Debajyoti Maitra]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 05:54:35 GMT</pubDate>
            <atom:updated>2026-11-12T05:56:33.172Z</atom:updated>
            <content:encoded><![CDATA[<p>Background</p><p><strong>MSI (PCIe on x86):</strong> A PCIe device writes a specific <strong>Message Data(Interrupt vector)</strong> value to a specific <strong>Message Address(target CPU APIC ID)</strong> in the 0xFEExxxxx(0xFEE00000–0xFEEFFFFF) physical memory (MMIO) address range allocated to the <strong>Local APIC (LAPIC)</strong> of the target CPU. This write is performed as a <strong>Memory Write TLP</strong> sent to the <strong>Root Complex</strong>, which routes (and optionally remaps via the IOMMU) the transaction to the target LAPIC to trigger the interrupt.</p><p>The LAPIC intercepts memory writes to the 0xFEExxxxx physical address space and decodes the target CPU ID, delivery mode, and vector directly from the <strong>address</strong> and <strong>data</strong> fields of the incoming transaction.</p><p><strong>IOMMU / Interrupt Remapping:</strong> In modern systems with virtualization or IOMMU enabled (such as Intel VT-d or AMD-Vi), the <strong>Root Complex</strong> does not blindly forward the write to the LAPIC. Instead, the <strong>IOMMU intercepts the MSI memory write</strong>, validates it against an Interrupt Remapping Table (IRT), and translates it before passing the interrupt to the target LAPIC.</p><p>Main Agenda</p><p>The core difference between <strong>MSI and MSI-X</strong> lies in how many interrupts a device can send and how their target addresses are stored, while the difference between <strong>x86 and ARM AArch64</strong> lies in <strong>which hardware component receives the Memory Write TLP</strong>.</p><p>1. MSI vs. MSI-X (Protocol &amp; Storage Differences)</p><p>Both MSI and MSI-X use the exact same PCIe <strong>Memory Write TLP</strong> mechanism on the wire. The difference is in the configuration capabilities exposed by the PCIe device:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BK4r3ym0q2tCsQ2qWnWKw.png" /><figcaption>MSI vs MSI-X</figcaption></figure><p>2. x86 vs. ARM AArch64 (Target Hardware Differences)</p><p>A PCIe device is architecture-agnostic — it simply executes a Memory Write TLP to a physical address programmed by the OS. What happens after that TLP hits the Root Complex depends on the CPU architecture:</p><ul><li><strong>x86 / x86_64 (LAPIC):</strong> There is no separate hardware controller needed to translate the write into an interrupt. The <strong>Local APIC (LAPIC)</strong> of each CPU core directly owns a fixed physical address window (0xFEE00000–0xFEEFFFFF). The target <strong>CPU APIC ID</strong> is encoded inside the <strong>Message Address</strong>, and the <strong>Interrupt Vector</strong> is encoded inside the <strong>Message Data</strong>.</li><li><strong>ARM AArch64 (GICv3 / GICv4 ITS):</strong> ARM cores do not have LAPICs; they use a <strong>Generic Interrupt Controller (GIC)</strong>. Modern ARM systems use an <strong>ITS (Interrupt Translation Service)</strong> block inside the GIC. The PCIe device writes to a special GIC doorbell register (GITS_TRANSLATER). The ITS uses the <strong>DeviceID</strong> (from the PCIe Requester ID / BDF) and the <strong>EventID</strong> (the written Message Data) to look up the target CPU core and interrupt ID (LPI) in memory-resident translation tables.</li></ul><p>3. Matrix Comparison Across Combinations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKLbUKI2awkpjrGT-F-HpQ.png" /><figcaption>MSI/MSI-X in x86/ARM</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9406f01942c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>