write a simple memory management simulator in C that supports paging. In this setup the logical address space (216= 65,536 bytes) is larger than the physical address space (215 bytes), and the page size is 256 bytes. The maximum no. of entries in the TLB (Translation Lookaside Buffer) = 16. memory.c - You are to provide your solution in a single C program named memory.c. Your simulator needs to accomplish the following: 1. Simulate a memory management unit (MMU), which translates logical addresses to physical addresses 1. Translating a logical address to physical address in this setup will involve the following: Check TLB for the page. If page not found in the TLB, check the page table if the page exists in memory. If it does not, then a page fault occurs. 2. Handling page faults involves copy the page from the backing store to memory. Since logical address space is larger than physical address space, a page request might involve replacing a page in memory with the new page. The page replacement policy to be used is FIFO page replacement policy. Your assignment is divided into the following three parts: MMU - Address Translation Your program will translate logical to physical addresses using a page table as outlined in the lecture notes under paging. 1. To simulate a program's memory address requests, we use the text file 'addresses.txt' (provided with Assignment). This file contains integer values representing logical addresses ranging from 0 -65535 (the size of the logical address space). 2. Your program will open this file using the fopen() library function and read each logical address from the file and compute its page number and offset using bitwise operators in C. Also, see notes on bitwise operators in C mentioned in Lab 7. 3. After extracting the page number from the logical address your program will look up the TLB. In the case of a TLB-hit (an entry corresponding to a page number exists), the frame number is obtained from the TLB. In the case of a TLB-miss (NO entry corresponding to the page number exists), look up the page table. In the latter case either the frame number is obtained from the page table, or a page fault occurs. 4. The page table can simply be an array. Since the system implements demand paging, initially all the entries of the page table can be set to -1 to indicate a page is not in memory. | MMU - TLB 1. To simulate entries of TLB in your program you may create a data structure called TLBentry which stores page number and frame number pair. 2. You will need three functions related to the TLB: 1. A search TLB function - To search the TLB for an entry corresponding to a page number. 2. A TLB Add function - To add an entry to the TLB. Since TLB uses the FIFO policy, if TLB is full, any entry added to the TLB replaces the oldest entry. 3. A TLB_Update function - To update the TLB when a page 'p' is replaced in physical memory, and an entry corresponding to page ‘p' exists in the TLB. Normally this would require removing this page's entry from the TLB, shuffling the TLB contents to maintain the FIFO order, and adding the new page entry at the top of the TLB. However, to simplify the assignment you may handle the update function by simply adding the new page entry at the same location as that of the page p. 3. All of the above mentioned functionality can be achieved by implementing the TLB as a circular array. Note: It is recommended that you bypass the TLB and use only a page table initially, and once have your program working correctly integrate the TLB. Note that, address translation can work without a TLB; the TLB just makes it faster. you

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
write a simple memory management simulator in C that supports paging. In this setup the
logical address space (216= 65,536 bytes) is larger than the physical address space (215 bytes),
and the page size is 256 bytes. The maximum no. of entries in the TLB (Translation
Lookaside Buffer) = 16.
memory.c - You are to provide your solution in a single C program named memory.c.
Your simulator needs to accomplish the following:
1. Simulate a memory management unit (MMU), which translates logical addresses to
physical addresses
1. Translating a logical address to physical address in this setup will involve the following:
Check TLB for the page. If page not found in the TLB, check the page table if the page
exists in memory. If it does not, then a page fault occurs.
2. Handling page faults involves copy the page from the backing store to memory. Since
logical address space is larger than physical address space, a page request might
involve replacing a page in memory with the new page. The page replacement policy to
be used is FIFO page replacement policy.
Transcribed Image Text:write a simple memory management simulator in C that supports paging. In this setup the logical address space (216= 65,536 bytes) is larger than the physical address space (215 bytes), and the page size is 256 bytes. The maximum no. of entries in the TLB (Translation Lookaside Buffer) = 16. memory.c - You are to provide your solution in a single C program named memory.c. Your simulator needs to accomplish the following: 1. Simulate a memory management unit (MMU), which translates logical addresses to physical addresses 1. Translating a logical address to physical address in this setup will involve the following: Check TLB for the page. If page not found in the TLB, check the page table if the page exists in memory. If it does not, then a page fault occurs. 2. Handling page faults involves copy the page from the backing store to memory. Since logical address space is larger than physical address space, a page request might involve replacing a page in memory with the new page. The page replacement policy to be used is FIFO page replacement policy.
Your assignment is divided into the following three parts:
MMU - Address Translation
Your program will translate logical to physical addresses using a page table as outlined in the
lecture notes under paging.
1. To simulate a program's memory address requests, we use the text file 'addresses.txt' (provided
with Assignment). This file contains integer values representing logical addresses ranging from 0
-65535 (the size of the logical address space).
2. Your program will open this file using the fopen() library function and read each logical address
from the file and compute its page number and offset using bitwise operators in C. Also, see
notes on bitwise operators in C mentioned in Lab 7.
3. After extracting the page number from the logical address your program will look up the TLB. In
the case of a TLB-hit (an entry corresponding to a page number exists), the frame number is
obtained from the TLB. In the case of a TLB-miss (NO entry corresponding to the page number
exists), look up the page table. In the latter case either the frame number is obtained from the
page table, or a page fault occurs.
4. The page table can simply be an array. Since the system implements demand paging, initially
all the entries of the page table can be set to -1 to indicate a page is not in memory. |
MMU - TLB
1. To simulate entries of TLB in your program you may create a data structure called TLBentry
which stores page number and frame number pair.
2. You will need three functions related to the TLB:
1. A search TLB function - To search the TLB for an entry corresponding to a page
number.
2. A TLB Add function - To add an entry to the TLB. Since TLB uses the FIFO policy, if
TLB is full, any entry added to the TLB replaces the oldest entry.
3. A TLB_Update function - To update the TLB when a page 'p' is replaced in physical
memory, and an entry corresponding to page ‘p' exists in the TLB. Normally this would
require removing this page's entry from the TLB, shuffling the TLB contents to maintain
the FIFO order, and adding the new page entry at the top of the TLB. However, to
simplify the assignment you may handle the update function by simply adding the
new page entry at the same location as that of the page p.
3. All of the above mentioned functionality can be achieved by implementing the TLB as a circular
array.
Note: It is recommended that you bypass the TLB and use only a page table initially, and once
have
your program working correctly integrate the TLB. Note that, address translation can
work without a TLB; the TLB just makes it faster.
you
Transcribed Image Text:Your assignment is divided into the following three parts: MMU - Address Translation Your program will translate logical to physical addresses using a page table as outlined in the lecture notes under paging. 1. To simulate a program's memory address requests, we use the text file 'addresses.txt' (provided with Assignment). This file contains integer values representing logical addresses ranging from 0 -65535 (the size of the logical address space). 2. Your program will open this file using the fopen() library function and read each logical address from the file and compute its page number and offset using bitwise operators in C. Also, see notes on bitwise operators in C mentioned in Lab 7. 3. After extracting the page number from the logical address your program will look up the TLB. In the case of a TLB-hit (an entry corresponding to a page number exists), the frame number is obtained from the TLB. In the case of a TLB-miss (NO entry corresponding to the page number exists), look up the page table. In the latter case either the frame number is obtained from the page table, or a page fault occurs. 4. The page table can simply be an array. Since the system implements demand paging, initially all the entries of the page table can be set to -1 to indicate a page is not in memory. | MMU - TLB 1. To simulate entries of TLB in your program you may create a data structure called TLBentry which stores page number and frame number pair. 2. You will need three functions related to the TLB: 1. A search TLB function - To search the TLB for an entry corresponding to a page number. 2. A TLB Add function - To add an entry to the TLB. Since TLB uses the FIFO policy, if TLB is full, any entry added to the TLB replaces the oldest entry. 3. A TLB_Update function - To update the TLB when a page 'p' is replaced in physical memory, and an entry corresponding to page ‘p' exists in the TLB. Normally this would require removing this page's entry from the TLB, shuffling the TLB contents to maintain the FIFO order, and adding the new page entry at the top of the TLB. However, to simplify the assignment you may handle the update function by simply adding the new page entry at the same location as that of the page p. 3. All of the above mentioned functionality can be achieved by implementing the TLB as a circular array. Note: It is recommended that you bypass the TLB and use only a page table initially, and once have your program working correctly integrate the TLB. Note that, address translation can work without a TLB; the TLB just makes it faster. you
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY