Recall & Review
beginner
What is static memory allocation in embedded C?
Static memory allocation means reserving memory at compile time before the program runs. The size and location of memory are fixed and do not change during execution.
Click to reveal answer
beginner
How does static memory allocation differ from dynamic memory allocation?
Static memory allocation reserves memory at compile time with fixed size, while dynamic memory allocation reserves memory at runtime and can change size during execution.
Click to reveal answer
beginner
Give an example of static memory allocation in embedded C.
Example: <br>
int buffer[100]; // Array of 100 integers allocated staticallyThis array size and memory location are fixed at compile time.
Click to reveal answer
intermediate
Why is static memory allocation preferred in embedded systems?
Because embedded systems often have limited memory and no operating system, static allocation avoids runtime overhead and fragmentation, making programs more predictable and reliable.
Click to reveal answer
intermediate
What are common static memory allocation patterns in embedded C?
Common patterns include:<br>- Global variables<br>- Static local variables<br>- Fixed-size arrays<br>- Constant data in read-only memory<br>These ensure memory is reserved at compile time.
Click to reveal answer
Which of the following is an example of static memory allocation?
✗ Incorrect
int arr[50]; allocates memory at compile time (static). malloc() and realloc() allocate memory at runtime (dynamic).
Why is static memory allocation safer in embedded systems?
✗ Incorrect
Static allocation avoids fragmentation and unpredictable behavior because memory is fixed at compile time.
Which keyword in C declares a variable with static storage duration inside a function?
✗ Incorrect
The 'static' keyword inside a function keeps the variable alive for the program's lifetime with fixed memory.
What happens if you declare a global array in embedded C?
✗ Incorrect
Global variables and arrays are allocated statically at compile time in embedded C.
Which of these is NOT a benefit of static memory allocation in embedded systems?
✗ Incorrect
Static allocation cannot resize memory dynamically; that is a feature of dynamic allocation.
Explain static memory allocation and why it is important in embedded C programming.
Think about how embedded devices have limited memory and no OS.
You got /4 concepts.
List common static memory allocation patterns used in embedded C and describe their purpose.
Consider where memory is reserved before the program runs.
You got /5 concepts.