Week 4 – CST– 334 Operating
System
Module 4 – Memory Virtualization
Continued
This week we continued learning about memory
virtualization. We were introduced to paging. In contrast to segmentation,
where we chop up memory into variable size pieces, with paging, we used
fixed-sized pieces. The logical memory space is divided into fixed-sized units
called pages, and the corresponding fixed-sized slots in physical memory are
called page frames. The virtual address space assigned to each process depends
on the architecture. A 32-bit architecture, for example, will have a virtual
address space of 4GB (232). Paging does not lead to external fragmentation
and allows the spares use of virtual address space.
Along with paging, we learned about the
Translation Look-aside Buffer or TLB. The TLB is a part of the MMU and is a
hardware cache of popular virtual-to-physical address translation. When a
virtual memory is referenced, the hardware checks the TLB to see if the desired
address translation is in there. If it is, the translation is quickly performed
without the need to check the page table. When the page requested is in the TLB,
it is considered a TLB hit, and the opposite is considered a TLB miss. When the
request is a miss, the hardware needs to access the page table to find the
translation and update the TLB with the translation. After the TLB is updated,
the hardware retries the instruction and finds the translation in the TLB.
We also learned of a Hybrid approach to
paging. In this approach, we use paging and segmentation. We use fixed-sized
pages with logical segments code, heap, and stack. Each of these segments have
their pair of base/bounds. The base register contains each segment’s physical address
on a linear page table for that segment. This means that each process has three
page tables associated with it. On a context switch, the registers change to
keep track of the location of the page tables of the new running process.
In chapter 21 of the text, we learned
about swap space. This allows the OS to give the illusion of a large virtual memory
for multiple concurrently running processes. A swap space is a reserved space
on the disk for moving pages back and forth. The way the OS determines if the
page is not in physical memory is by using the present bit on the page table
entry. If the present bit is set to one, then the page is present in physical
memory. If it is set to zero, the page is not in physical memory. This
generates a page fault and the page must be swapped from disk.
Lastly, we learned about Physical Memory
Policies. These policies are regarding cache memory management. The goal of the
replacement policies is to generate the fewest misses overall. You must replace
the pages that will be accessed furthest in the future. The FIFO replacement
policy is the first in first out policy. It replaces the page that came in
first. A random algorithm randomly removes pages from the cache. The most
popular algorithm is the Least-Recently-Used or LRU. This policy replaces the
least-recently-used page. It uses history to remove pages. If a page is requested
that is in the cache, it moves it up and kicks out the least recently used. For
example, if the cache has pages 1,2,3 and page 3 is requested, it generates a
hit and the new order will be 3,1,2. If the next request is page number 4, it
will generate a miss and the new order will be 4,3,1 kicking out page 2.
Comments
Post a Comment