Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C programming language create a my_malloc and my_free which implement a simple memory allocator using a linked list and a first-fit allocation scheme. Your

in C programming language

create a my_malloc and my_free which implement a simple memory allocator using a linked list and a first-fit allocation scheme.

Your my_malloc function will: Round up the size of the requested allocation to a certain size (I gave you this) Try to find a block to reuse, using first-fit allocation If it found a block, and that block can be split into two smaller blocks, do so If it couldnt find a block, expand the heap by moving the break with sbrk() Mark it as used Return the pointer to the data part (after the header)

Your my_free function will: Figure out the pointer to the header Mark the block free Coalesce it with any neighboring blocks on either side If its the last block on the heap, contract the heap by moving the break with sbrk()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe conciliation and arbitration.

Answered: 1 week ago

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago