In Section 9.2, we presented different algorithms for contiguousmemory allocation. This project will involve managing a contiguousregion of memory of size MAX where addresses may range from 0 …MAX − 1. Your program must respond to four different requests:Request for a contiguous block of memory Release of a contiguousblock of memory Compact unused holes of memory into one singleblock Report the regions of free and allocated memory Your programwill be passed the initial amount of memory at startup. Forexample, the following initializes the program with 1 MB (1,048,576bytes) of memory: ./allocator 1048576 Once your program hasstarted, it will present the user with the following prompt:allocator> It will then respond to the following commands: RQ(request), RL (release), C (compact), STAT (status report), and X(exit). A request for 40,000 bytes will appear as follows:allocator>RQ P0 40000 W 1 $IBQUFS .BJO .FNPSZ Similarly, arelease will appear as: allocator>RL P0 This command willrelease the memory that has been allocated to process P0. Thecommand for compaction is entered as: allocator>C This commandwill compact unused holes of memory into one region. Finally, theSTAT command for reporting the status of memory is entered as:allocator>STAT Given this command, your program will report theregions of memory that are allocated and the regions that areunused. For example, one possible arrangement of memory allocationwould be as follows: Addresses [0:315000] Process P1 Addresses[315001: 512500] Process P3 Addresses [512501:625575] UnusedAddresses [625575:725100] Process P6 Addresses [725001] . . .”MMPDBUJOH .FNPSZ Your program will allocate memory using one ofthe three approaches highlighted in Section 9.2.2, depending on thefag that is passed to the RQ command. The fags are: • F—frst ft •B—best ft • W—worst ft This will require that your program keeptrack of the different holes representing available memory. When arequest for memory arrives, it will allocate the memory from one ofthe available holes based on the allocation strategy. If there isinsuffcient memory to allocate to a request, it will output anerror message and reject the request. Your program will also needto keep track of which region of memory has been allocated to whichprocess. This is necessary to support the STAT The frst parameterto the RQ command is the new process that requires the memory,followed by the amount of memory being requested, and fnally thestrategy. (In this situation, “W” refers to worst ft.) command andis also needed when memory is released via the RL command, as theprocess releasing memory is passed to this command. If a partitionbeing released is adjacent to an existing hole, be sure to combinethe two holes into a single hole. 1 #JCMJPHSBQIZ $PNQBDUJPO If theuser enters the C command, your program will compact the set ofholes into one larger hole. For example, if you have four separateholes of size 550 KB, 375 KB, 1,900 KB, and 4,500 KB, your programwill combine these four holes into one large hole of size 7,325 KB.There are several strategies for implementing compaction, one ofwhich is suggested in Section 9.2.3. Be sure to update thebeginning address of any processes that have been affected bycompaction.
Expert Answer
Answer to In Section 9.2, we presented different algorithms for contiguous memory allocation. This project will involve managing …