Operating System: Virtual Memory, TLB, and Page Replacement

Verified

Added on  2023/04/24

|7
|870
|248
Homework Assignment
AI Summary
This assignment solution delves into the core concepts of operating systems, specifically focusing on virtual memory management and the Translation Lookaside Buffer (TLB). The solution addresses questions related to page mapping, swapping, and the role of the TLB in address translation. It explains how logical addresses are converted to physical addresses and how the system handles TLB misses and page faults. The assignment includes a code simulation that reads addresses from a file, translates logical addresses to physical addresses, and calculates page fault and TLB hit rates. The provided code demonstrates the implementation of a TLB and a page replacement algorithm. The document concludes with the output of the program, showcasing the virtual and physical address mappings, and includes a bibliography of relevant academic resources.
Document Page
Running head: OPERATING SYSTEM
Operating System
Name of the Student
Name of the University
Author’s Note
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
1
OPERATING SYSTEM
Answer to Question 1:
The pages in physical memory is owned by the systems. The pages are contiguous
blocks of fixed length and can be described as a single entry in page table. The pages are
mapped with the operating system and it can be transferred between the hard drive and
known as paging or swapping. For the extraction of the page number the logical address is
used and TLB is consulted for obtaining the frame number. In case the TLB is missed the
page table is consulted and frame number is fetched.
The system is responsible for mapping the physical memory with the virtual memory
addresses. It also automatically manages the space of physical memory transparently and thus
the programmer is needed to know the size of physical memory for running any program. The
physical memory acts as a cache for the pages stored on the disk and mapping with any
physical frame.
Answer to Question 2:
During replacement of an entry in the TLB there is need to write it back to the
physical memory. This is can be described form the demand paging where a backing store is
used for the management of page fault. For storing the frame the page table and TLB are
updated and the access of the page is resolved either by page table or the TLB. The backing
store file is needed to be treated as random access file such that certain position of the file can
be seek for reading.
Answer to Question 3:
TLB consists of mapped virtual page number for the physical page number and
includes the present bit, referenced bits, protection, dirty bits and process ID. It also contains
Document Page
2
OPERATING SYSTEM
98% of the pages that are accessed and the size ranges from 64 to 128 entries. Smaller TLB is
fully associative and page fault and TLB miss is also different from each other.
For the simulation the program is written for reding 1001 addresses ranging from 0 to
65535 and the logical address is translated into physical addresses. The contents of the signed
bytes are determined and outputs the translated logical addresses read from the
addresses23.txt file, physical address of the corresponding logical address and signed byte
value stored for the translated physical address.
while((read = getline(&line, &len, pFile)) != -1){
int offset = atoi(line) & 255;
int page = atoi(line) & 65280;
int page_table_number = page >> 8;
int tlb_hit = 0;
for(int i = 0; i < TLB_SIZE; i++){
if(tlb[i][0] == page_table_number){
tlb_hit = 1;
printf("TLB HIT\n");
break;
}
}
if(v_memory[page_table_number][0] < 0 && !tlb_hit){
pageFaultCount++;
Document Page
3
OPERATING SYSTEM
srand(time(NULL));
int r = rand();
int largest = 0;
int evct = 0;
for(int i = 0; i < V_SIZE; i++){
if(v_memory[i][1] > largest){
largest = v_memory[i][1];
evct = i;
}
}
int tlb_replacement = r % 15;
tlb[tlb_replacement][0] = page_table_number;
tlb[tlb_replacement][1] = v_memory[evct][0];
v_memory[page_table_number][0] = v_memory[evct][0];
v_memory[page_table_number][1] = 0;
v_memory[evct][0] = -1;
v_memory[evct][1] = 0;
}
A statistics is generated after completing the program listing the page fault rate and
the TLB hit rate.
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
4
OPERATING SYSTEM
Document Page
5
OPERATING SYSTEM
The following is the output obtained after executing the program and it lists the virtual
address read from the provided txt file and the physical address of the corresponding logical
address.
Document Page
6
OPERATING SYSTEM
Bibliography
Ausavarungnirun, R., Landgraf, J., Miller, V., Ghose, S., Gandhi, J., Rossbach, C. J., &
Mutlu, O. (2017, October). Mosaic: a GPU memory manager with application-
transparent support for multiple page sizes. In Proceedings of the 50th Annual
IEEE/ACM International Symposium on Microarchitecture (pp. 136-150). ACM.
Yıldırım, A. A., Watson, D., Tarboton, D., & Wallace, R. M. (2015). A virtual tile approach
to raster-based calculations of large digital elevation models in a shared-memory
system. Computers & geosciences, 82, 78-88.
chevron_up_icon
1 out of 7
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]