VerbalDescription of the Project (Dynamic Memory Allocation)

VerbalDescription of the Project (Dynamic Memory Allocation)Most modern programming such asC, C++, and Java have a facility to request memory of any size (sufficient forstoring the data of a structure or object) from the operating system dynamicallyat execution time using system calls e.g., mallocor new. The Operating System allocates the requested amount memory from apool, and restores it back to the pool, when the user program returns theearlier requested memory using system calls e.g. dealloc or free. You maynote that this type of memory allocation is different from static allocation atcompile time for different fixed size data structures such as arrays.Inthis project, you need to write MIPS code for dynamic allocation of memory. Inother words, you need to write a main program that keeps on waiting in a loopfor user’s request through console for allocation/deallocation of memory of asize for a variable with a name, and calls an allocation or a deallocationprocedure accordingly. The allocation procedure allocates an available chunk(that is, a chunk not allocated to another variable) of memory, and updates ittable to indicate which portions of its memory are allocated to whichvariables, and which portions of memory are still available. When the mainprogram requests the deallocation procedure to free a portion of memoryallocated to a variable, the procedure will mark those portions of the memoryearlier allocated this variable as free. The allocation and deallocationrequests may come from the user in any order, and a possible complication yourproject needs to handle is the situation where there may not be enough contiguous memory to handle anallocation request through the total free memory areas total up to a valuehigher than the requested amount. For easier design and test of your project,you may make the following simplifying assumptions:Thepool of memory is very limited, say 2048 bytes.Thepool is partitioned into small chunks of equal size (say, 32 bytes each sothat in a pool of 2048 bytes there will 64 chunks). Thoughmemory requests could come for any size, allocation is always done in theintegral number of chunks. That is, if a request for 100 bytes comes, 128bytes (or 4 chunks) are allocated.Ideasfor Design: You need to have a symbol table or a mapping ofmemory variables and the range of the numbers of the chunks allocated. You alsoneed a free/available table or a Boolean array of the size of the total chunksin your dynamic memory; allocated chunks needs to be ticked (marked with 1),and the free slots need to be marked as zero. Initially, all slots are markedas zero.After a series of “allocate”and “deallocate” requests, the free areas may not be contiguous in the sensethat they may have memory area currently being used in between therebypreventing coalescing of the free areas into a single larger block. Hence, inorder to meet the request for a memory of a particular size, a search for acontiguous memory area of the requested size is required to be made on thefree/available list. In case, no free block is available, the program shouldprint the error message indicating unavailability of large enough memory blockto satisfy the request. In case of availability of large enough free blocks,there are two possible design policies: i) First-Fit: allocate the firstavailable large enough free block on the list, and ii) Best Fit: Search thewhole list and allocate the free area closer in size to the requested amount.Both have their own advantages, and disadvantages; you need to discuss these,and explain why you made this choice.