Reference no: EM132409336
Programming Assignment
Goals
Learn how the internal operations of malloc() and free() work.
Complete a heap allocator using the implicit free list data structure.
Implement the allocate, free, split, and coalesce heap operations.
Building the Project
Accept your assignment here and clone to your Cloud9 environment.
Only use Cloud9 for writing, compiling, and running this project. If you complete your project on your personal computer and it does not compile and run on Cloud9, you will not receive credit.
Compile/build your project by running
Allocating the Default Heap Block
When the cis20 library is initialized, you must create the default heap block. This unallocated block will exist to start the heap. It may not be the first block used because it only has a size of 24 bytes. Remember that 8 bytes of every block are reserved for the header and footer. Thus, a 24 byte block only has 8 bytes available to store user program data!
Run the first test file to ensure that the test runs
How to Split a Free Block
Block splitting only occurs during allocation. In fact, block_split is already called by the cis20_alloc function, but it does not do anything useful yet.
By default, the block_split function does not actually split the block, instead it just returns the size of the block.
The intent of the function is to split large blocks when not all of the block space is needed. This is meant to be an optimization so that excessive fragmentation can be avoided.
The split operation takes a few steps:
1. Resize the original block to match the requested size.
2. Create a new block after the original block by writing a header and footer with the block size and marked as unallocated.
3. Return the requested size to indicate that the original block has changed sizes.
The implementation of this algorithm is entirely up to you
Attachment:- Programming Assignment.rar