Welcome to Assignments Writing

Your Trusted Partner in Term Paper Writing

At Assignments Writing, we’re a team of passionate educators and skilled writers committed to supporting students in their academic journey.

NVCC Programming Dynamic Memory Management Schemes Project

NVCC Programming Dynamic Memory Management Schemes Project

ANSWER

Creating a complete implementation of the malloc, free, calloc, and realloc functions, along with the requested features, is a complex task that involves a significant amount of code. I can provide you with a high-level outline of how you can approach this task and some important concepts you’ll need to understand. You will need to write the actual code based on this outline.

Here is a simplified outline:

  1. Implementing a Memory Manager:
    • You will need to maintain a data structure to manage the allocated and free blocks of memory. This data structure will be used to keep track of available memory and allocate memory when requested.
  2. Implement malloc Functionality:
    • Allocate memory from the available free blocks. You will need to search for a suitable free block based on the requested size.
    • If the free block is larger than the requested size, split it into two blocks: one for the requested size and another for the remaining free memory.
  3. Implement free Functionality:
    • When free is called, mark the allocated block as free. You should also merge adjacent free blocks to avoid fragmentation.
  4. Implement calloc Functionality:
    • Implementing calloc is similar to malloc, but you also need to initialize the allocated memory to zero.
  5. Implement realloc Functionality:
    • realloc involves changing the size of an already allocated block. You may need to allocate a new block, copy data from the old block to the new one, and then free the old block.
  6. Tracking Memory Leaks:
    • To track memory leaks, you should keep a record of all allocated blocks. When the program exits, you can check this record to see if any blocks were not freed.
  7. Implementing a Doubly Linked List:
    • Modify the memory manager data structure to use a doubly linked list to keep track of free and allocated blocks.
  8. Implementing Best Fit Algorithm:
    • Modify the allocation strategy to use the best fit algorithm. This involves finding the smallest free block that can accommodate the requested size.
  9. Bonus Points:
    • To minimize wasted space, you can implement a function to split blocks into smaller ones when they are larger than needed.
    • Implement a mechanism to merge adjacent free blocks together to avoid fragmentation.
  10. Testing and Profiling:
    • Write a main function to test your memory manager. Allocate and free memory blocks multiple times to test various scenarios.
    • Measure memory usage and fragmentation to demonstrate the efficiency of your implementation.
  11. Reporting:
    • Create a report that explains your implementation, highlights any issues or limitations, and presents memory leak statistics for different test cases.

Remember that this is a complex task, and you will need a good understanding of memory management and data structures to complete it successfully. You can refer to the tutorial you mentioned for guidance on implementing the basic memory manager functions and adapt them to meet the requirements of your assignment.

NVCC Programming Dynamic Memory Management Schemes Project

QUESTION

Description

 

 

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

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 out
the heap start/end addresses and (ii) print out the memory leaks in your code. In your report, explain how you
calculated 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 to
all 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 fit
algorithm instead.

4. Your code must use the set-up mentioned in this tutorial. Other online resources can be consulted but
NOT copied. The tutorial mentions some other implementations for splitting/merging blocks that can only be
consulted 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 function
definitions, (c) a .c file with the driver main() function, (d) a Makefile to compile your code and (e) a report
showing the memory leak values. Submit both the improved versions of the functions and the preliminary
implementations from the tutorial. Additionally, mention which portions of your code are working and which
portions don’t and why in your report. Your report should show the memory leaks for varying number of calls to
malloc/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 the
space. 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 small
blocks that can only be re-used when we ask for small amounts of space. Implement a mechanism to merge
adjacent free blocks together so that any consecutive free blocks will get merged into a single block.

Place Your Order Here

Our Service Charter


1. Professional & Expert Writers: We only hire the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of master’s and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. We are known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: We have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

Format & Features

Our Advantages

How It Works

1. Fill Order Form
2. Make payment
3. Writing process
4. Download paper

Fill in the order form and submit all your files, including instructions, rubrics, and other information given to you by your instructor.

Once you complete filling the forms, complete your payment. We will get the order and assign it to a writer.

When your order is completed, it’s assigned to an editor for approval. The editor approves the order.

Once approved, we will upload the order to your account for you to download.  You can rate your writer or give your customer review.

What Clients Said

{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

5
Mercy M
{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

5
Jane L
{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

4.5
Rayan M

LET US DELIVER YOUR ACADEMIC PAPER ON TIME!

We are a freelance academic writing company geared towards provision of high quality academic papers to students worldwide.

Open chat
1
Scan the code
Hello
Can we help you?