NVCC Programming Dynamic Memory Management Schemes Project

Develop a C program to implement the “malloc”, “free”, “calloc” and “realloc” functionalities.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Instructions:

1. Check out the malloc tutorial from Dan Luu on how these functions can be implemented at:

http://danluu.com/malloc-tutorial/The tutorial implements working versions of malloc, free, calloc and realloc and you can use that code as-is.2. Write a driver function (i.e., main function) to demonstrate the usage and efficiency of these functions.The main() should have at least 10 calls each to malloc, calloc, realloc and free. Set up the function to (i) print outthe heap start/end addresses and (ii) print out the memory leaks in your code. In your report, explain how youcalculated memory leaks in this case.3. Your main task is to implement the exercises mentioned in the tutorial. These are also shown below:(a) Convert the single linked list implementation of the tutorial into a doubly linked list version; make changes toall the functions accordingly to work with the doubly linked list.(b) The current implementation implements a first fit algorithm for finding free blocks. Implement a best fitalgorithm instead.4. Your code must use the set-up mentioned in this tutorial. Other online resources can be consulted butNOT copied. The tutorial mentions some other implementations for splitting/merging blocks that can only beconsulted but not copied.To turn in:1. You will need 4 files: (a) a header file with all the function prototypes, (b) a .c file with all the functiondefinitions, (c) a .c file with the driver main() function, (d) a Makefile to compile your code and (e) a reportshowing the memory leak values. Submit both the improved versions of the functions and the preliminaryimplementations from the tutorial. Additionally, mention which portions of your code are working and whichportions don’t and why in your report. Your report should show the memory leaks for varying number of calls tomalloc/calloc/realloc/free.Bonus Points (a) The implemented malloc is really wasteful if we try to re-use an existing block and we don’t need all of thespace. Implement a function that will split up blocks so that they use the minimum amount of space necessary.(b) After doing (a), if we call malloc and free lots of times with random sizes, we’ll end up with a bunch of smallblocks that can only be re-used when we ask for small amounts of space. Implement a mechanism to mergeadjacent free blocks together so that any consecutive free blocks will get merged into a single block.

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER