CS 449 – Midterm 2 Practice Problems
1.) For the program below, what will the stack look like if execution is paused at the line marked HERE? (You may ignore padding and alignment.)
int g(char *a) { //HERE return strlen(a); }
int main() { int y; y = g(“hello”); return 0; }
|
|
2.) Answer the following about a memory region of 20 MB that has a chunk size of 1MB that is managed with a linked list using best fit allocation.
a.) Assume the region is initially empty. Show the list after allocations of size 4, 6, 3, and 2 (in that order).
b.) From the list in part (a), free the 6 and 3 MB chunks. What is the resulting linked list?
c.) Finally, a request for a chunk of size 4 occurs. Show the linked list from part (b) with the new allocation.
3.) Write a macro that finds the minimum of its three arguments.