Introduction In this assignment you will implement a small Memory Management System (MMS), that simulates what a real Op

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Introduction In this assignment you will implement a small Memory Management System (MMS), that simulates what a real Op

Post by answerhappygod »

Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 1
Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 1 (73.46 KiB) Viewed 43 times
Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 2
Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 2 (41.21 KiB) Viewed 43 times
Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 3
Introduction In This Assignment You Will Implement A Small Memory Management System Mms That Simulates What A Real Op 3 (50.25 KiB) Viewed 43 times
Introduction In this assignment you will implement a small Memory Management System (MMS), that simulates what a real Operating System does when its programs (called processes) dynamically ask for (or give back) pieces of memory (called blocks). Your MMS must manage the memory, which can be viewed as an array of bytes. Note: you are not to generate such an array, just manage it, Your program will have to satisfy requests of the following type: alloc <process name> <number of bytes> means find a continuous piece of memory of size <number of bytes> and assign it to process <process name>. For example, alloc my_process 5 allocates 5 consecutive bytes of memory to the process my_process. Notes that we do not care where the piece of memory actually starts. free <process name> means free (i.e. give back to MMS) all the blocks allocated to the process named <process name>. printfree means print a list of all the free (unoccupied) blocks, i.e. where each starts and its size.
A typical driver program will look like this: } public static void main (String[] args) { MMS myMem = new MMS (100); myMem.printalloc(); myMem.printfree (); myMem.alloc ("pgmA", 50); } myMem.printalloc(); myMem.printfree (); myMem.alloc("pgmB", 20); myMem.printalloc(); myMem.print free (); myMem.alloc ("pgmA", 10); myMem.printalloc(); myMem.printfree (); myMem. free ("pgmB"); myMem.printalloc(); myMem.printfree (); myMem.alloc("pgmD", 25); myMem.printalloc(); myMem.printfree ();
Below are some suggestions for the implementation. Create a record that will have the following fields process Name start size String the name of the process to which this block has been allocated. address where this block starts. size, in number of bytes, of this block. pointer to the next record. nextPiece pointer You should keep two lists. One, the freelist, points to a list of free blocks, and the other, the alloclist, to the list of allocated blocks. In the beginning, the entire memory being managed should be in one freelist record, and the alloclist should be empty. On receiving the request alloc pgma 50, your MMS should scan the freelist for the first block whose size is greater than or equal to 50. When found, the MMS will allocate the required amount of memory to pgmA and return any unused portion of the block to the freelist. Notice that the size of the returned portion will be smaller by 50. There is no need to keep freelist records for blocks of length 0, but you can, if you so choose. On receiving the free pgna command, your MMS will traverse the alloclist and return to the freelist all of the blocks currently allocated to process pgma. MMS should also keep track of the total free memory, i.e. the sum of the sizes of the free block. This will allow MMS to quickly return an overflow error message if an alloc request asks for more space than is available. Your MMS should continue running if this happens. Subsequent free commands will again provide memory to allocate. It is possible that the total free memory is large enough to satisfy the request, but no individual block in the freelist is big enough. This situation is called fragmentation Here, your MMS should perform garbage collection, i.e. take all the free pieces of memory and join them together to create one big piece of memory that can satisfy more requests. This is done by moving (shifting) the allocated blocks down so they start from address and are consecutive. It is advisable to keep the records in the alloclist ordered by the starting address. The garbage collection then becomes straightforward, otherwise it becomes a nightmare. There are two other possible techniques for allocating memory. Smallest fit, in which MMS checks the entire freelist and selects the smallest piece that satisfies the request. Largest fit, in which MMS checks the entire freelist and selects the largest piece that satisfies the request. You are only implementing first fit.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply