Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

****NB: Programming Question By C Programming Guestion By C code: Heap allocation management. The heap is essentially one large contiguous space that goes from 0

****NB: Programming Question By C

image text in transcribed

image text in transcribed

image text in transcribed

Programming Guestion By C code: Heap allocation management. The heap is essentially one large contiguous space that goes from 0 to n-1 (where n is the size of the heap). The simplest way to manage the heap is to do a first-fit allocation. You start from the beginning and you use the first hole that can satisfy the request. Once found you take what you need to service the request. You are to develop a simple heap management system The size of the heap is to be read in from the command line. Create 10 threads that will request a random size of memory less then the heap size, sleep for a random period of time (up to 10 seconds and then release the memory they were allocated. Use 2 linked lists to track the allocated memory partitions and the free memory partitions. The threads will need to be able to access these lists to update them ensure thread safety. The nodes will contain: o ID of process the memory is allocated to (1 to number of threads) o Size of the memory requested (less then the size of the heap) o Start address o End address Write functions that support the following operations: (a) A function allocator() which is called by the threads this function will assign a unique ID to each thread (this can be done simply with a counter) and then call the allocate() function, have the thread sleep and then call the release() function. (b) A function allocate(int id, int numBytes) allocates a number of bytes from the heap adds a node to the list of allocated partitions, updates the list of free memory (holes). If the memory could not be allocated return -1. Each time display the list of allocated and free memory

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

Question What are the requirements for a safe harbor 401(k) plan?30

Answered: 1 week ago