Question: In C: a) Give code for next(p), a function that, given the pointer to a block, returns the pointer to the next block. b) Give
In C:
a) Give code for next(p), a function that, given the pointer to a block, returns the pointer to the next block.
b) Give code for status(p), a function that, given the pointer to a block, returns the tag bit (0 or 1).
c) Give code for previous(p), a function that, given the pointer to a block, returns a pointer to the previous block.
3. Background: Consider a boundary tag heap manager where each tag contains a pointer to the tag for the next block, a pointer to the tag for the previous block, and the status of the block (free or in use). Pointers are one word each, but because the size of each block is always in integer number of words (in order to guarangee that the pointers are aligned on word boundaries), the least significant bit of each pointer can be used. Therefore, boundary tags in this system have the following form: previous next this block previous: a full word pointer to the previous block next: a full word pointer to the next block except the least significant bit t: a one bit tag, where 1 means in use, 0 means free In the following, assume that the address of a block is always a void* pointer to the first word of the block itself. Use types void* and intptr_t, where possible, to make your code work with any word size. The next pointer and tag bit is always the word just before the block and the previous pointer is always the word before that
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
