Interview Questions Flashcards

(5 cards)

1
Q

What’s a circular buffer

A

a fixed-size, FIFO (first-in, first-out) data structure that acts as if its end is connected back to its beginning, forming a circle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why would you use a Circular Buffer instead of a standard Array to handle incoming data from a sensor?

A

A circular buffer allows you to constantly add new data and read old data without ever needing to “shift” elements (which is slow). Once the buffer is full, it simply wraps around to the beginning. This is $O(1)$ efficiency, which is critical for real-time systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In an embedded C program, what is a “Stack Overflow,” and what usually causes it?

A

A Stack Overflow occurs when the “Stack” memory (used for local variables and function return addresses) runs out of space and starts overwriting other memory. It is usually caused by deep recursion or declaring massive local arrays (e.g., int buffer[1000] inside a function) that exceed the allocated stack size.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the advantage of using a struct with bit-fields when interacting with hardware registers?

A

Bit-fields allow you to map specific bits of a register to meaningful names. This makes the code much more readable and less error-prone than manually using bit-masks and shifts every time you want to change a single setting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why might an RTOS use a Linked List to manage “Ready Tasks” instead of an Array?

A

Linked lists allow for $O(1)$ insertion and deletion of tasks. If a high-priority task suddenly becomes “Ready,” the RTOS can quickly move that node to the front of the list without moving every other task in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly