Answered step by step
Verified Expert Solution
Question
1 Approved Answer
15 10 . bits Header Q4. (30 pts) Consider a memory allocator with the following properties: Allocations are 4-byte aligned, for each memory block, either
15 10 . bits Header Q4. (30 pts) Consider a memory allocator with the following properties: Allocations are 4-byte aligned, for each memory block, either allocated or free Allocator uses an implicit free list Allocator uses immediate coalescing, that is, adjacent free blocks are merged immediately each time a block is freed To find a free block, first fit method is used The allocated and free blocks both have header and footer Block size (bytes) The header and footer use: the higher order 14 bits to record block size (block size includes the header and footer) . the lower order 2 bits to record allocation information: Block size (bytes) bit o indicates the use of current block: 1 for allocated, O for free bit 1 indicates the use of previous adjacent block: 1 for allocatedO for free If the heap starts at memory address OxB000, show the contents of heap after each of the following request. Note that the address grows from top to down. Footer pl = malloc (3) p2 = malloc (5) free (p1) p3 - malloc (9) free (p2) a) Draw the heap b) Indicate the memory location that p1, p2, and p3 points at c) Indicate each memory block either allocated or free. d) Give the value of header and footer for each block in hexadecimal). Also, indicate the change in header and footer if there is any 45 minutes for this session 15 10 . bits Header Q4. (30 pts) Consider a memory allocator with the following properties: Allocations are 4-byte aligned, for each memory block, either allocated or free Allocator uses an implicit free list Allocator uses immediate coalescing, that is, adjacent free blocks are merged immediately each time a block is freed To find a free block, first fit method is used The allocated and free blocks both have header and footer Block size (bytes) The header and footer use: the higher order 14 bits to record block size (block size includes the header and footer) . the lower order 2 bits to record allocation information: Block size (bytes) bit o indicates the use of current block: 1 for allocated, O for free bit 1 indicates the use of previous adjacent block: 1 for allocatedO for free If the heap starts at memory address OxB000, show the contents of heap after each of the following request. Note that the address grows from top to down. Footer pl = malloc (3) p2 = malloc (5) free (p1) p3 - malloc (9) free (p2) a) Draw the heap b) Indicate the memory location that p1, p2, and p3 points at c) Indicate each memory block either allocated or free. d) Give the value of header and footer for each block in hexadecimal). Also, indicate the change in header and footer if there is any 45 minutes for this session
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started