C CODE ONLY Memory Management: The goal of this project is to practice the address translation that is usually performed

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

C CODE ONLY Memory Management: The goal of this project is to practice the address translation that is usually performed

Post by answerhappygod »

C CODE ONLY
Memory Management:
The goal of this project is to practice the address translationthat is usually performed by the hardware and practice themanagement of a page table. In this assignment, you are asked todesign a simulator that simulates memory management inside the userspace.
We consider a tiny computer system (even much smaller thanRaspberry Pi) that supports up to 1KB physical memory and 12-bitvirtual addresses. The size of a virtual page and a physical pageis 128 bytes.
Part1:
Assume that the page table of the process is shown in thefollowing diagram.
C Code Only Memory Management The Goal Of This Project Is To Practice The Address Translation That Is Usually Performed 1
C Code Only Memory Management The Goal Of This Project Is To Practice The Address Translation That Is Usually Performed 1 (47.81 KiB) Viewed 12 times
Note that only a few entries of the process' page table arepresent, as we will only use the first seven entries inpart1.Write a program called mempart1.c for this part. The program willtake only one parameter, the input sequence filename, whichcontains a sequence of virtual memory accesses (addresses). Here,each address is stored as 8 bytes (unsigned long type). Yourprogram should read and analyze each virtual address and translateit into the corresponding physical address base on the given pagetable (shown in the above diagram). Note: to simplify yourimplementation, you may hard code the page-to-frame mapping in yourprogram.In the input file, each memory address is stored in a binaryformat. You should not attempt to to view the file by the command"cat", "less", or any text editing application. Instead, you mayuse "hexdump input_file" command to view the binary contents. Youcan test your program with the givensimple test file , where the first addressshould be 0x00000044, and the second one should be 0x00000224.Physical address for these two virtual addresses should be 0x144and 0x01A4.For each address in the input file, you will use the above givenpage table to perform the address translation, and generate acorresponding physical address. You will output the translatedphysical addresses into an output file, named "part1output". Thisoutput file should have a similar format to the given "part1test"file, i.e., each physical address should use 8 bytes (as anunsigned long value). In this assignment, we represent each virtualand physical address using 64-bit (8 bytes) to enable the programto be more general.Once you test your program correctly with the above simple testfile, which contains only 8 virtual addresses, you should use thislarger input file as the input file andplace all the physical addresses in another file called "part1out".Then you can use the md5sum utility to compute the correspondingchecksum, via running "md5sum part1out", and you only need to writethe checksum into a file called "p1result.txt".
Part2:
In this part, you will design the page table and deal withallocations of physical machines on the same machine as discussedabove. You will create two new source files: phyframe.c andpagetable.c, as well as a new main program, named "mempart2.c",plus any necessary header files. Here, phyframe.c is used to managethe physical frames, while pagetable.c will hold all functions thatmanage the page table for the process.For this part, we will also assume the first physical frame isreserved for the OS, while other framess are initially availablefor the process. To manage physical frames, you will use a simplephysical page allocation scheme: You will allocate each physicalpage in the order of frame number initially, starting from 1, 2, 3,.... If physical frames are available, you will always allocatefrom these available frames at first. Once there are no freephysical frames, you will need to use LRU page replacement policyto choose a physical frame to be replaced, which means the leastrecently used page will be the first to be evicted.Note that once a frame is selected to be replaced, you should dotwo things:First, you should update the old page table entry such that no twovirtual pages are pointing to the same physical frame. In reality,it is better to quickly locate which page table entry is actuallypointing to this physical frame, typically called as ``reversemapping''. However, you may search the whole page table of allactive processes (one process in the assignment) to find out this,with significant performance overhead.
IMPORTANT: CIS 545 students must design and implement areverse mapping scheme. Otherwise, you will automatically lose 15points. For CIS 345 students, 10 bonus points will be givento implement a reverse mapping scheme. Please includenecessary design description in your README file.Second, you should change the page table entry of the target pageto point to the frame. If you are using the "reverse mapping"mechanism, you should also set up the reverse mappingcorrectly.Note: you can use any mechanism discussed in the class to implementthe strict LRU policy, such as counter mechanism, but notsecond-chance algorithm. Importantly, you should update thecorresponding information upon each access.The input sequence of the program is the same as that used in Part1. Thus, you should be able to utilize the same parser to obtainthe corresponding virtual address, then translate it to a physicaladdress with your implemented page table.In the end, you can use the same function as in Part1 to output thetranslated physical address sequence into an output file. You areprovided a part2 input file, named " part2input ".Similar to Part1, you only need to report the md5sum of your outputfile. and write it to p2result.txt. In addition, your programshould report the number of page faults encountered for the givenaccess sequence, and this number should be reported in p2result.txtfile too.
9 8 7 6 5 4 3 2 1 0 I I I I 6 5 3 7 1 4 2 Page table 7 6 5 4 3 2 1 0 Physical frames
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply