Category: coding interview prep

  • Top Interview Questions on Interrupt Service Routine (ISR) | Master Embedded Interview Guide (2026)

    Interview Questions on Interrupt Service Routine : When preparing for embedded systems interviews, one of the most important topics is the Interrupt Service Routine (ISR). Recruiters often ask questions on ISR because it is a core concept in microcontrollers, operating systems, and real-time systems. In this guide, we’ll go through commonly asked ISR interview questions, explained in a simple way for beginners.

    What is an Interrupt Service Routine (ISR)?

    An Interrupt Service Routine (ISR) is a special block of code that executes when a hardware or software interrupt occurs. Instead of continuously checking a condition (polling), the system pauses its normal execution and jumps to the ISR to handle the event immediately.

    Example: When you press a button on a microcontroller, an interrupt occurs, and the ISR handles the button press.

    Interview Questions on Interrupt Service Routine
    Top Interview Questions on Interrupt Service Routine (ISR) Master Embedded Interview Guide (2025)

    Common Interview Questions on Interrupt Service Routine (ISR)

    1. What is an ISR in embedded systems?

    Answer: An ISR is a function that handles interrupts. It is triggered automatically when an interrupt occurs, allowing the CPU to respond quickly to external or internal events.

    2. What are the characteristics of an ISR?

    Answer:

    • Fast execution : Should be short and efficient.
    • No return values : ISR does not return values.
    • No blocking calls : Avoid using functions like delay() inside ISR.
    • Context saving : CPU saves the current state before jumping to ISR.

    3. Can an ISR call another function?

    Answer: Yes, but it should only call lightweight functions. Heavy operations inside ISR may slow down the system and block other interrupts.

    4. What are nested interrupts?

    Answer: Nested interrupts occur when a higher-priority interrupt occurs while another ISR is still running. In such cases, the CPU pauses the current ISR and executes the higher-priority one.

    5. Why should we keep ISRs short?

    Answer: Long ISRs delay the processing of other interrupts. In real-time systems, this can cause missed events and system instability.

    6. What is the difference between ISR and a normal function?

    Answer:

    • ISR executes automatically when an interrupt occurs, while a normal function is called manually.
    • ISR does not return values, while functions can.
    • ISR runs in a special CPU context and must be as short as possible.

    7. Can we use global variables inside ISR?

    Answer: Yes, but they must be declared as volatile so that the compiler does not optimize them. This ensures real-time updates between the ISR and the main program.

    8. What is interrupt latency?

    Answer: Interrupt latency is the time delay between an interrupt request and the start of ISR execution. Low latency is important for real-time systems.

    9. How do you handle multiple interrupts?

    Answer:

    • Assign priority levels to interrupts.
    • Use interrupt vectors to map different ISRs.
    • Ensure critical ISRs are shorter and higher priority.

    10. What are some best practices for writing ISRs?

    Answer:

    • Keep ISRs short and simple.
    • Use global variables carefully (mark them as volatile).
    • Avoid using printf, malloc, or delay inside ISR.
    • Handle only critical tasks inside ISR and defer others to the main loop or task scheduler.

    List of Interview Questions on Interrupt Service Routine (ISR)

    Basic Questions of Interrupt Service Routine interview questions

    1. What is an Interrupt Service Routine (ISR)?
    2. Why do we need ISR in embedded systems?
    3. What are the main features of an ISR?
    4. What is the difference between polling and ISR?
    5. What happens when an interrupt occurs?

    Intermediate Questions of ISR in embedded systems

    1. What are the rules for writing an ISR?
    2. Why should an ISR be short and fast?
    3. Can we use global variables inside ISR?
    4. What is the role of the volatile keyword in ISR?
    5. What is interrupt latency?
    6. Can an ISR return a value? Why or why not?
    7. What is the difference between ISR and a normal function?
    8. Can ISRs be nested? What are nested interrupts?
    9. How does the CPU know which ISR to execute?
    10. What is an interrupt vector table?

    Advanced Questions of common ISR interview questions

    1. How are multiple interrupts handled in a system?
    2. What are interrupt priorities?
    3. What is the difference between maskable and non-maskable interrupts?
    4. What are reentrant and non-reentrant ISRs?
    5. Can we use dynamic memory allocation (malloc/free) inside ISR?
    6. Why is it not recommended to use printf() inside ISR?
    7. What are some common mistakes while writing ISRs?
    8. How do you handle critical tasks inside ISR?
    9. What happens if an ISR takes too long to execute?
    10. How do modern microcontrollers reduce interrupt latency?

    Practical/Implementation Questions of interrupt handling in embedded systems

    1. How do you declare an ISR in C/C++?
    2. How do you enable and disable interrupts in a microcontroller?
    3. What is the difference between hardware and software interrupts?
    4. Can an ISR call another ISR?
    5. How do you share data between ISR and the main program?
    6. What are best practices for writing ISRs?
    7. What tools or debuggers can be used to test ISR execution?
    8. Can an ISR cause a system crash? How?
    9. How does an operating system handle interrupts differently from bare-metal programming?
    10. What is the difference between vectored and non-vectored interrupts?

    1.What is an Interrupt Service Routine (ISR)?

    Ans: An ISR is a special function that executes automatically when an interrupt occurs, allowing the CPU to handle events quickly without polling.

    2.Why do we use ISR in embedded systems?

    Ans: ISR reduces CPU load, improves response time, and makes systems more efficient by handling events only when they occur.

    3. Can an ISR return a value?

    Ans: No, ISRs cannot return values because they are executed by hardware/OS, not called like regular functions.

    4. Why should ISR be short and fast?

    Ans: Long ISRs block other interrupts and can cause system delays or missed events.

    5. Can we use global variables in ISR?

    Ans: Yes, but they should be declared as volatile to ensure real-time updates between ISR and the main program.

    6. What is interrupt latency?

    Ans: Interrupt latency is the time delay between an interrupt request and the start of ISR execution.

    7. Can we use printf or delay inside ISR?

    Ans: No, functions like printf, malloc, or delay should be avoided inside ISR as they are slow and may cause system instability.

    8. What is the difference between ISR and normal function?

    Ans:
    a) ISR executes automatically when an interrupt occurs, while a normal function is called explicitly.
    b) ISR does not return values, while functions can.
    c) ISR runs in a special CPU context.

    9. What are nested interrupts?

    Ans: Nested interrupts occur when a higher-priority interrupt interrupts the execution of a lower-priority ISR.

    10. What are best practices for writing ISRs?

    Ans:
    a) Keep ISRs short and efficient.
    b) Use volatile for shared variables.
    c) Avoid blocking functions.
    d) Handle only critical tasks inside ISR, defer the rest to main loop or task scheduler.
    Interrupt Service Routine
    Interrupt Service Routine (ISR) Definition, Examples, Best Practices Embedded Interview Guide (2025)
  • Differences between RISC and CISC | Master Embedded Interview Guide (2026)

    Differences between RISC and CISC : Discover the differences between RISC and CISC processors, their advantages, disadvantages, and applications in computers and embedded systems. Learn which processor architecture suits your needs

    Differences between RISC and CISC

    In the world of computer architecture, RISC and CISC are two foundational processor designs that have shaped how modern computers work. Understanding these architectures is essential for students, engineers, and tech enthusiasts who want to deepen their knowledge of computer processors and embedded systems. In this article, we will explain what RISC and CISC are, their differences, advantages, disadvantages, and real-world applications.

    What is RISC (Reduced Instruction Set Computer)?

    RISC stands for Reduced Instruction Set Computer. It is a type of microprocessor architecture that uses a small set of simple instructions, allowing the processor to execute instructions faster. The main idea behind RISC is simplicity and efficiency. Each instruction is designed to perform a very basic operation, which typically completes in one clock cycle.

    Key Features of RISC

    • Simplified Instructions: Executes basic instructions only.
    • Uniform Instruction Length: All instructions usually have the same size.
    • Load/Store Architecture: Memory access is done only through specific instructions.
    • Faster Execution: Due to simplicity, pipelines can be implemented efficiently.
    • Low Power Consumption: Less complex hardware reduces energy usage.

    Advantages of RISC

    • High performance for simple instructions.
    • Easier to design and optimize pipelines.
    • Efficient for embedded systems and mobile devices.

    Disadvantages of RISC

    • Requires more instructions to perform complex tasks.
    • Larger program size due to the higher number of instructions.

    Examples of RISC Processors

    • ARM (Advanced RISC Machine)
    • MIPS (Microprocessor without Interlocked Pipeline Stages)
    • SPARC (Scalable Processor Architecture)

    What is CISC (Complex Instruction Set Computer)?

    CISC stands for Complex Instruction Set Computer. Unlike RISC, CISC processors use a large set of instructions, including complex operations that can perform multiple tasks in a single instruction. The main goal of CISC is to reduce the number of instructions per program, even if it increases the complexity of each instruction.

    Key Features of CISC

    • Complex Instructions: Each instruction can perform multiple low-level operations.
    • Variable Instruction Length: Instructions can have different sizes.
    • Memory-to-Memory Operations: Allows operations directly on memory without using registers.
    • Fewer Instructions per Program: Reduces the need for repetitive coding.

    Advantages of CISC

    • Reduced program size.
    • Easier for programmers to implement complex algorithms.
    • More powerful instructions can simplify software development.

    Disadvantages of CISC

    • Slower execution due to instruction complexity.
    • More power consumption and heat generation.
    • Complex design and harder to optimize pipelines.

    Examples of CISC Processors

    • Intel x86 Series
    • VAX (Virtual Address eXtension)
    • IBM System/360

    Differences between RISC and CISC

    FeatureRISCCISC
    Full FormReduced Instruction Set ComputerComplex Instruction Set Computer
    Instruction SetSimple and smallLarge and complex
    ExecutionSingle clock cycle per instructionMultiple clock cycles per instruction
    Memory AccessLoad/Store instructions onlyMemory-to-memory instructions allowed
    Program SizeLargerSmaller
    Hardware ComplexitySimpleComplex
    ExamplesARM, MIPS, SPARCIntel x86, VAX

    Applications of RISC and CISC

    • RISC Processors are commonly used in smartphones, tablets, embedded systems, and IoT devices because of their efficiency and low power consumption.
    • CISC Processors dominate personal computers, servers, and workstations, where performance and complex computations are required.

    Why Understanding RISC and CISC is Important

    Knowing the difference between RISC and CISC helps in:

    • Selecting the right processor architecture for specific applications.
    • Optimizing software for performance and energy efficiency.
    • Understanding the evolution of modern CPUs and embedded systems.

    Conclusion of topic Differences between RISC and CISC

    Both RISC and CISC architectures have their own advantages and use cases. While RISC focuses on simplicity and speed, making it ideal for mobile and embedded devices, CISC emphasizes powerful instructions and ease of programming, making it suitable for desktops and servers. Understanding these architectures is crucial for anyone working in computer engineering, embedded systems, or software development.

    Frequently Asked Questions (FAQ) | Differences between RISC and CISC

    1. What is the difference between RISC and CISC?
    RISC (Reduced Instruction Set Computer) uses a small set of simple instructions executed quickly, while CISC (Complex Instruction Set Computer) uses a large set of complex instructions, often requiring multiple clock cycles.

    2. Which is better, RISC or CISC?
    It depends on the application. RISC is ideal for embedded systems and mobile devices due to efficiency and low power consumption, whereas CISC is suited for desktops and servers requiring complex computations.

    3. What are some examples of RISC processors?
    Popular RISC processors include ARM, MIPS, and SPARC.

    4. What are some examples of CISC processors?
    Common CISC processors include Intel x86 series, VAX, and IBM System/360.

    5. Why do RISC processors use simpler instructions?
    RISC processors focus on simplicity to allow faster execution, efficient pipelining, and lower power consumption.

    6. Does CISC reduce program size?
    Yes, CISC’s complex instructions allow multiple operations in a single instruction, reducing the overall program size.

    7. What is the main application of RISC and CISC architectures?
    RISC is widely used in smartphones, tablets, and IoT devices, while CISC dominates personal computers, servers, and workstations.

    8. Can a processor be both RISC and CISC?
    Modern processors often incorporate hybrid designs, combining RISC efficiency with some complex CISC instructions for compatibility.

    Differences between RISC and CISC
    Differences between RISC and CISC Master Embedded Interview Guide (2025)
  • Master Circular Linked List Tutorials with Examples 2026

    Complete guide to mastering Circular Linked Lists in 2025 with this beginner-to-advanced tutorial! Learn how circular linked lists work, their types, operations, and real-life applications through clear explanations, code examples in C, C++, Java, Python, and JavaScript, and step-by-step implementations. This post also covers time and space complexity, interview FAQs, help you crack coding interviews and academic exams. Perfect for students, developers, and data structure enthusiasts!

    What is a Circular Linked List?

    A Circular Linked List is a variation of the linked list in which the last node points back to the first node instead of pointing to NULL. This creates a looped structure where you can traverse endlessly through the list starting from any node.

    🔁 In a circular linked list, you can go from tail to head seamlessly — it’s like a roundabout with no end!

    Why Learn Circular Linked Lists?

    Learning about Circular Linked Lists is crucial for understanding how dynamic data structures work in memory. They are especially useful for:

    • Circular buffers (ring buffers)
    • Multiplayer game round-robin scheduling
    • Task scheduling algorithms
    • Data streaming

    Types of Circular Linked List

    1. Singly Circular Linked List
      Each node has a data and a next pointer, and the next of the last node points to the first node.
    2. Doubly Circular Linked List
      Each node has data, next, and prev pointers. The next of the last node connects to the first node and the prev of the first node connects to the last.

    Circular Linked List Operations

    1. Insertion

    • At the beginning
    • At the end
    • After a specific node

    2. Deletion

    • From the beginning
    • From the end
    • A specific node

    3. Traversal

    • Start from any node and keep moving until you’re back to the same node.
    // Example: Circular Linked List Traversal in C
    void traverse(struct Node* head) {
        struct Node* temp = head;
        if (head != NULL) {
            do {
                printf("%d ", temp->data);
                temp = temp->next;
            } while (temp != head);
        }
    }
    

    C Implementation CLL

    #include <stdio.h>
    #include <stdlib.h>
    
    struct Node {
        int data;
        struct Node* next;
    };
    
    void traverse(struct Node* head) {
        if (head == NULL) return;
        struct Node* temp = head;
        do {
            printf("%d ", temp->data);
            temp = temp->next;
        } while (temp != head);
    }
    
    struct Node* insertEnd(struct Node* head, int data) {
        struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
        newNode->data = data;
        if (!head) {
            newNode->next = newNode;
            return newNode;
        }
        struct Node* temp = head;
        while (temp->next != head) temp = temp->next;
        temp->next = newNode;
        newNode->next = head;
        return head;
    }
    

    ✅ C++ Implementation CLL

    #include <iostream>
    using namespace std;
    
    class Node {
    public:
        int data;
        Node* next;
        Node(int val) {
            data = val;
            next = nullptr;
        }
    };
    
    void traverse(Node* head) {
        if (!head) return;
        Node* temp = head;
        do {
            cout << temp->data << " ";
            temp = temp->next;
        } while (temp != head);
    }
    
    Node* insertEnd(Node* head, int val) {
        Node* newNode = new Node(val);
        if (!head) {
            newNode->next = newNode;
            return newNode;
        }
        Node* temp = head;
        while (temp->next != head) temp = temp->next;
        temp->next = newNode;
        newNode->next = head;
        return head;
    }
    

    ✅ Java Implementation CLL

    class Node {
        int data;
        Node next;
        Node(int data) {
            this.data = data;
            this.next = null;
        }
    }
    
    public class CircularLinkedList {
        Node head;
    
        void traverse() {
            if (head == null) return;
            Node temp = head;
            do {
                System.out.print(temp.data + " ");
                temp = temp.next;
            } while (temp != head);
        }
    
        void insertEnd(int data) {
            Node newNode = new Node(data);
            if (head == null) {
                newNode.next = newNode;
                head = newNode;
                return;
            }
            Node temp = head;
            while (temp.next != head) temp = temp.next;
            temp.next = newNode;
            newNode.next = head;
        }
    }
    

    ✅ Python Implementation CLL

    class Node:
        def __init__(self, data):
            self.data = data
            self.next = None
    
    class CircularLinkedList:
        def __init__(self):
            self.head = None
    
        def traverse(self):
            if not self.head:
                return
            temp = self.head
            while True:
                print(temp.data, end=' ')
                temp = temp.next
                if temp == self.head:
                    break
    
        def insert_end(self, data):
            new_node = Node(data)
            if not self.head:
                new_node.next = new_node
                self.head = new_node
                return
            temp = self.head
            while temp.next != self.head:
                temp = temp.next
            temp.next = new_node
            new_node.next = self.head
    

    ✅ JavaScript Implementation CLL

    class Node {
        constructor(data) {
            this.data = data;
            this.next = null;
        }
    }
    
    class CircularLinkedList {
        constructor() {
            this.head = null;
        }
    
        traverse() {
            if (!this.head) return;
            let temp = this.head;
            do {
                console.log(temp.data);
                temp = temp.next;
            } while (temp !== this.head);
        }
    
        insertEnd(data) {
            const newNode = new Node(data);
            if (!this.head) {
                newNode.next = newNode;
                this.head = newNode;
                return;
            }
            let temp = this.head;
            while (temp.next !== this.head) {
                temp = temp.next;
            }
            temp.next = newNode;
            newNode.next = this.head;
        }
    }
    

    Time & Space Complexity of Circular Linked List

    OperationTime ComplexitySpace Complexity
    Insert at EndO(n)O(1)
    TraverseO(n)O(1)
    Delete NodeO(n)O(1)
    SearchO(n)O(1)

    ⚠️ Note: You can make insertion O(1) by maintaining a tail pointer.

    Advantages of Circular Linked List

    • No NULL value at the end
    • Ideal for implementing circular queues
    • Efficient for round-robin scheduling
    • Can traverse from any node

    Disadvantages of Circular Linked List

    • Slightly more complex insertion/deletion logic
    • Risk of infinite loops if not handled properly

    Circular Linked List vs Singly Linked List

    FeatureSingly Linked ListCircular Linked List
    End PointerPoints to NULLPoints to head node
    TraversalEnds at NULLLoops back to start
    Use CaseLinear dataCircular scheduling

    Real-world Use Cases of Circular Linked List

    • Music playlist apps (loop through songs)
    • Task scheduling in OS
    • Live data streams
    • Circular queues

    1.What is the use of circular linked list?

    It is mainly used in applications that require a continuous traversal like CPU scheduling, music players, or multiplayer games.

    2.What is the time complexity of circular linked list operations?

    Insertion: O(1) (beginning), O(n) (end/after a node)
    Deletion: O(1) (beginning), O(n) (specific node)
    Traversal: O(n)

    3.Can we implement a stack or queue using a circular linked list?

    Yes! Circular linked lists are great for queues, especially when a circular buffer is needed.

    4.How to detect a circular linked list?

    Use Floyd’s Cycle Detection Algorithm (Tortoise and Hare method).

    5.What is a Circular Linked List in Data Structures?

    A Circular Linked List is a type of linked list where the last node is connected back to the first node, forming a closed loop. Unlike a singly linked list where the last node points to NULL, a circular linked list enables continuous traversal from any point in the list. This structure is highly useful in circular queues, CPU scheduling, and real-time applications.

    6.What are the types of Circular Linked Lists?

    There are two main types of Circular Linked Lists:
    Singly Circular Linked List: Each node has one pointer pointing to the next node, and the last node points to the head.
    Doubly Circular Linked List: Each node has two pointers (prev and next), and both the first and last nodes are connected circularly in both directions.
    Both types are used based on the complexity of operations needed and memory constraints.

    7.What are the real-life applications of Circular Linked List?

    Circular Linked Lists are widely used in:
    Round-robin CPU scheduling
    Music or video playlists that auto-repeat
    Circular buffers in embedded systems
    Real-time data stream processing
    Traffic light simulation systems
    Multiplayer games for turn rotation
    These applications benefit from the list’s looping behavior, which avoids end-condition checks.

    8.What is the time complexity of Circular Linked List operations?

    Insertion at end/head: O(n) / O(1) (if tail maintained)
    Deletion at head: O(n)
    Search: O(n)
    Traversal: O(n)
    Maintaining a tail pointer can reduce insertion time at the end to O(1).

    9.How do you detect a circular linked list in a program?

    To detect a circular linked list, you can use Floyd’s Cycle Detection Algorithm (Tortoise and Hare Algorithm):
    Use two pointers moving at different speeds.
    If they ever meet, a cycle exists.
    If the fast pointer reaches NULL, it’s not circular.
    This is the most efficient method with O(n) time and O(1) space.

    10.Can a Circular Linked List be used to implement a queue?

    Yes, Circular Linked Lists are perfect for circular queues, especially when:
    Memory usage is fixed (as in embedded systems).
    You need constant-time insertion and deletion.
    It avoids shifting elements (like in arrays) and supports continuous enqueuing and dequeuing.

    A Circular Linked List offers flexibility, especially when your use case involves continuous looping or round-based tasks. While it can be a bit more complex than a regular linked list, it brings efficiency and circular logic into dynamic data structures.

    If you’re preparing for coding interviews, learning circular linked lists will give you an edge!

    Circular Linked List
    Master Circular Linked List Tutorials with Examples 2025