Designing a virtual memory manager

Assignment Help C/C++ Programming
Reference no: EM131007541

Detailed Question: Assignment must be done in C, (using bitshift operators (>> or <<) and &.

Must have good comments and explain what is being done, (I will fix the write up myself, but a play by play of the code and explanation of what is happening is needed, so I can understandObjectives: The aim of this project is to help students understand the main concepts of memory management and virtual memory. Students will obtain hands on experience in programming such a system along with its features.

Designing a Virtual Memory Manager

This assignment consist of writing a program that translates logical to physical addresses for a virtual address space of 216 = 65,536 bytes. Your program will read from a file containing logical addresses and, using a TLB as well as a page table, will translate each logical address to its corresponding physical address and output the value of the byte stored at the translated physical address. Make sure your program uses fast operations like left/right shift operators.

Specifics

Your program will read a file containing several 32-bit integer numbers that represent logical addresses. However, you need only be concerned with 16-bit addresses, so you must mask the rightmost 16 bits of each logical address. These 16 bits are divided into (1) an 8-bit page number and (2) 8-bit page offset. Hence, the addresses are structured as follows:

Other specifics include the following:
• 28 entries in the page table
• Page size of 28 bytes
• Frame size of 28 bytes
• 256 frames
• Physical memory of 65,536 bytes (256 frames x 256-byte frame size)
Additionally, your program need only be concerned with reading logical addresses and translating them to their corresponding physical addresses. You do not need to support writing to the logical address space.

Address Translation

Your program will translate logical to physical addresses using as outlined in Chapters 7 and 8. The page number is extracted from the logical address and the frame number is obtained from the page table or a page fault occurs (check the valid-invalid bit). A visual representation of the address-translation process is as follows:

2246_Address Translation.jpg

Handling page Faults

Your program will implement demand paging as described in Chapter 8. The backing store is represented by the file BACKING_STORE.bin, a binary file of size 65,536 bytes. When a page fault occurs, you will read in a 256-byte page from the file BACKING_STORE and store it in an available page frame in physical memory. For example, if a logical address with page number 15 resulted in a page fault, your program would read in page 15 from BACKING_STORE (remember that pages begin at 0 and are 256 bytes in size) and store it in a page frame in physical memory. Once this frame is stored (and the page table and TLB are updated), subsequent accesses to page 15 will be resolved by the page table.

You will need to treat BACKING_STORE.bin as a random-access file so that you can randomly seek to certain positions of the file for reading. We suggest using the standard C library functions for performing I/O, including fopen(), fread(), fseek(), and fclose().

The size of the physical memory is the same as the size of the virtual address space (65,536 bytes) so you do not need to be concerned about page replacements during a page fault.

An extension to this virtual memory system is to use a smaller amount of physical memory which would require a page-replacement strategy - note that this is not required for this project.

Test file

The attachment contains a file addresses.txt, which contains integer values representing logical addresses ranging from 0 to 65535 (the size of the virtual address space). Your program will open this file, read each logical address and translate it to its corresponding physical address, and output the value of the signed byte at the physical address.

How to Begin

Frist, write a simple program that extracts the page number and offset (based on the figure above) from the following integer numbers
1, 256, 32768, 32769, 128, 65534, 33153

You are required to use the operators for bit-masking and bit-shifting.

How to Run Your Program
Your program should run as follows:

./a.out addresses.txt

Your program will read in the file addresses.txt, which contains 1,000 logical addresses ranging from 0 to 65535. Your program is to translate each logical address to a physical address and determine the contents of the signed byte stored at the correct physical address. (Recall that in C, the char data type occupies a byte of storage, and so we suggest using char values.)

Your program should output the following values:

1. The logical address being translated (the integer value being read from addresses.txt).

2. The corresponding physical address (what your program translates the logical address to).

3. The signed byte value stored at the translated physical address.

Another file called correct.txt is attached, which contains the correct output values for the file addresses.txt. You should use this file to determine if your program is correctly translating logical to physical addresses (we are concerned only about physical address).

Statistics
After completion, your program is to report the following statistics:

• Page-fault rate: The percentage of address references that resulted in page faults.

Since the logical addresses in addresses.txt were generated randomly and do not reflect any memory access locality, do not expect to have a high TLB hit rate. Comment on this in your report.

Attachment:- Assignment.rar

Reference no: EM131007541

Questions Cloud

Acts of terrorism : Acts of terrorism are intended to have an impact far beyond the death and destruction of the immediate attack. Mass fear and interruptions to normal daily functioning occur in the aftermath of terrorist attacks, like concentric surges that erupt w..
Strategic management and economic development : Each student is required to locate an organization that contributes to strategic management and economic development in the community.
Strategic management and economic development : Each student is required to locate an organization that contributes to strategic management and economic development in the community.
Identify two accounts of terrorism : Identify two accounts of terrorism and/or genocide from this week's readings and consider the affective, behavioral, cognitive, and ecological impact of each
Designing a virtual memory manager : our program is to translate each logical address to a physical address and determine the contents of the signed byte stored at the correct physical address
Analyze the military response to the mental health needs : In this Discussion, you will analyze the military's response to the mental health needs of combat veterans and any potential barriers to treatment that might exist
Calculate the pressure on the outer cylindrical surface : A cylindrical ring has an outer diameter D, an inner diameter d, and a width w. A solid cylindrical disk of diameter (d + Φd) and width w is press fit completely into the ring. If the ring were thin (i.e., (D-d) is very small), how could you calcul..
Identify risk and resilience factors : Identify risk and resilience factors related to pre-deployment, deployment, and post-deployment for both specialists in the case studies
Determine the principal stresses : For a critical three-dimensional state of stress where, sx = 45,000, sy = 25,000, sz = -50,000, txy = 4000, tyz = 2000, and tzx = -3500 psi, determine the principal stresses and draw the Mohr circle representation of the state of stress.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Function named sort that takes three integer parameter

Write a function named sort that takes three integer parameters by reference. The function should rearrange the parameter values so that the first parameter gets set to the smallest value, the second parameter gets set to the second smallest value, a..

  How many generations do you want to wait

How many generations do you want to wait? How many jackalopes do you have?

  Explain how to represent a lagged fibonacci generator

Explain how to represent a lagged Fibonacci generator using list abstract data types. What representation would be the most appropriate?

  Average and maximum error

The program uses the average and maximum error of the two values. c.

  Computes the final price for a sales transaction

Create a C program that contains a function that computes the final price for a sales transaction and return that value to a calling method.

  Create an array of slip objects

Create an array of Slip objects. You should populate the array with 10 slips, entering information into all fields of the Slip object. (Make sure that all customers have a valid slip number in their information, and mark that slip as rented.)

  rewrite that statement in a more readable style.

Give an example statement in C, C++, or Java that is particularly unreadable. Rewrite that statement in a more readable style.

  Implement the delivery company using the classes given in

implement the delivery company using the classes given in the class diagram above. construct a cpp file named

  Computing the standard deviation

Input Details: The scores are entered as numbers with or without decimal points. In response to the continuation prompts (described below) the user types a y or a Y to signify "continue" with any other character signifying "quit".

  Define a function named average grade

Define a function named average grade. This function returns a double and has four double arguments, testi, test2, test3, test4. The return value should be the average, or arithmetic mean of the four arguments.

  Elements that must be included in a loop

What are the three elements that must be included in a loop in order for the loop to successfully perform correctly - What will happen if these statements are not included? Provide examples.

  Computer programming using c language lab

Computer programming using c language lab

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd