logo

Memory Allocation Schemes for First Fit Worst Fit and Buddy System

   

Added on  2019-09-30

3 Pages1108 Words192 Views
DescriptionIn this project, you will implement four memory allocation schemes to manage a chunk of memory and mimicmalloc() and free() functions for a single thread system:1.First Fit2.Best Fit3.Worst Fit and4.Buddy System.The main() in the testcases will first use a standard glibc malloc() call to allocate a large amount of memory from the system. The specific amount of memory that your system will handle will be defined by a parameter mem_size which is a parameter of the setup() function. Your code will then use this memory to form and return the requested smaller chunks of memory to the subsequent my_malloc() calls. For the specifics and any latest updates make sure you keep checking this web-site for any latestinformation/updates regarding the project.DeliverablesYour project should implement the following interfaces in C programming language, and all these four schemes should be provided in a new file called my_memory.c. void setup(int malloc_type, int mem_size, void* start_of_memory);This function will be invoked once in the beginning of execution and is to be used for two purposes: 1.Initializating your implementation to the type of memory management scheme using the parameter malloc_type. It will contain values from 0 to 3, denoting 0 for First-Fit, 1 for Best-Fit, 2 for Worst-Fit and 3 for Buddy System.2.Providing with a contigous chunk of memory, whose starting address is passed in the argument, start_of_memory pointer and the size of this chunk is supplied by the parameter mem_size.The memory management schemes should use this chunk of memory pointed by start_of_memory for all subsequent my_malloc() allocations. void* my_malloc(int size);This function when invoked, should allocate a chunk of memory and return a pointer to the starting of the allocated memory chunk (which should be in the range from start_of_memory to start_of_memory + mem_size. The size of allocation is controlledby the argument size. Your implementation of this function should perform the necessary logic to track and maintain the allocated memory chunks, the free holes and their respective sizes so that it does not allocate the same address to more than one my_malloc() callees (before the address gets freed). Also, when the requested size is notallocatable this function should return (void *)-1.

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP
|11
|1080
|283