Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Write a program in C named allo following requirements cator.cthat sim ulates a dynamie memory allocation system, with the Accept a commandline argument for

image text in transcribed

image text in transcribed

image text in transcribed

Instructions Write a program in C named allo following requirements cator.cthat sim ulates a dynamie memory allocation system, with the Accept a commandline argument for the size of the heap to be simulated and use the malloc () system call to make space for the given size Give the user a menu of options: 1. malloc: Allocate memory within the heap for N bytes 2. free: Deallocate memory from the heap using relative address 3. coalesce: Detect and remove adjacent free regions 4. view: Traverse the free list and print its information as well as total overhead in bytes 5. quit: Exit the program Menu options 2 and 3 DO NOT need to be implemented for full credit. Sample Output $ ./allocator 4096 heap: 18436112, 0, size-4096 ALLOCATOR: ENTER AN OPTION 1. malloc 2. Iree 3. coalesce 4. view 5 quit CHOICE: 4 Traversing linked list of free regions. . . curr: 18436112, 0, size 4080 Total overhead: free regions:1 (16 bytes per) used chunks: 0 (4 bytes per) 16 bytes ALLOCATOR: ENTER AN OPTION 1. malloc 2. Iree 3. coalesce 4. vieiw 5. quit CHOICE: 1 ENTER THE SIZE IN BYTES: 100 ptr: 18436116, 4, size-100 ALLOCATOR: ENTER AN OPTION 1. malloc 2. Iree 3. coalesce 4. view 5. quit CHOICE: 1 ENTER THE SIZE IN BYTES: 300 ptr: 18436220, 108, size-300 ALLOCATOR: ENTER AN OPTION 1. malloc 2. Iree 3. coalesce 4. view 5. quit CHOICE: 1 ENTER THE SIZE IN BYTES: 200 ptr: 18436524, 412, size-200 ALLOCATOR: ENTER AN OPTION 1. malloc 2. Iree 3. coalesce 4. vieiw 5. quit CHOICE: 4 Traversing linked list of free regions. . . curr: 18436724, 612, size-3468 Total overhead: free regions 1 (16 bytes per) used chunks: 3 (4 bytes per) 28 bytes

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_2

Step: 3

blur-text-image_3

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

Data Science Project Ideas In Health Care Volume 1

Authors: Zemelak Goraga

1st Edition

B0CPX2RWPF, 979-8223791072

More Books

Students also viewed these Databases questions