C191-Terms-Chapter-8 Flashcards
Virtual memory (VM)
a collection of one or more logical address spaces, each of which may exceed the size of physical memory. A logical address is then referred to as a virtual address.
A paged VM creates a single large contiguous address space per process. A paged VM with segmentation creates multiple large address spaces per process, each of which is paged.
Demand paging
the principle of loading a page into memory only when the page is needed, rather than at the start of the execution.
present bit
a binary flag in each page table entry that indicates whether the corresponding page is currently resident in memory. If a page is resident, then the entry points to the frame that holds the page.
page fault
an interrupt that occurs when a program attempts to reference a non-resident page. The interrupt triggers the operating system to find the page on disk, copy the page into a frame, and set the present bit to 1.
Demand paging makes the implementation of VM possible by moving pages to main memory only as needed.
Page replacement
the act of overwriting a page in memory with a different page loaded from the disk when needed.
Moving pages between memory and the disk is very time consuming and must be minimized. When the page to be removed has not been modified during execution then an exact copy still exists on the disk and the page does not have to be copied back to the disk.
modified-bit (m-bit)
a binary flag in each page table entry that indicates whether the corresponding page has been modified during execution. The modified bit is set to 1 automatically by any instruction that stores data into the page and is used by the operating system to minimize the movement of data to dis
reference string
the sequence of page numbers referenced by an executing program during a given time interval. Reference strings are used to compare different page replacement algorithms by counting the number of page faults generated.
optimal page replacement algorithm
selects the page that will not be referenced for the longest time in the future.
The algorithm is guaranteed to generate the smallest number of page faults for any reference string.
However, the algorithm is unrealizable because the replacement decisions depend on future references, which are unknown at runtime. But the algorithm provides a useful lower bound on the number of page faults for comparison with other algorithms.
FIFO page replacement algorithm
selects the page that has been resident in memory for the longest time.
The algorithm is easy to implement, requiring only a single pointer to designate the oldest page in memory. When the page is replaced, the pointer is advanced to the next frame modulo n.
The FIFO algorithm takes advantage of the principle of locality. Except for branch instructions, which constitute only a small percentage of all instructions, execution is sequential.
As execution advances sequentially through the code, the likelihood of referencing a page used in the distant past diminishes with time. Similarly, many large data structures are processed in sequential order.
FIFO exploits the principle of locality to some degree but fails to recognize that a program frequently returns to pages referenced in the distant past.
FIFO replaces the oldest resident pages even if the pages have been referenced again recently and thus are likely to be referenced again in the near future.
The least-recently-used page replacement algorithm
selects the page that has not been referenced for the longest time. The LRU requires the queue of pages to be modified at each memory reference, which makes the algorithm too inefficient in practice.
The implementation requires a queue of length n, where n is the number of memory frames. The queue contains the numbers of all resident pages.
Whenever a resident page p is referenced, p is moved from the head to the end of the queue. Thus the queue is always sorted from least recently used page to most recently used page.
When a non-resident page p is referenced, p is moved to the end of the queue and the least recently referenced page q at the head of the queue is removed. Page p then replaces q in memory.
referenced bit (r-bit)
a bit associated with a page and is set automatically by the hardware whenever the page is referenced by any instruction.
aging register
is associated with a page and is shifted periodically to the right by 1 bit. Unless the most significant bit is set to 1, the page is aging in the sense that the associated register value is steadily decreasing.
aging page replacement algorithm
does not maintain pages sorted in the exact LRU order, but groups together pages referenced during a period of d consecutive references. Each period is represented by 1 bit in a periodically shifting aging register.
second-chance page replacement algorithm
a coarse-grain approximation of LRU. The algorithm uses the r-bit to divide all pages into only two categories: recently referenced and not recently referenced. A page is selected from the not-recently referenced category.
Similar to FIFO, the algorithm maintains a pointer that cycles through the pages when searching for a page to be replaced. Because of its circular nature, the algorithm is also known as the clock algorithm.
At a page fault, the algorithm repeats the following steps until a page is selected for replacement:
If the pointer is at a page p with r = 0 then select p and advance the pointer to the next page.
Otherwise, reset r to 0, advance the pointer to the next page, and continue the search.
The third-chance page replacement algorithm
The third-chance algorithm is a refinement of the second-chance algorithm. The algorithm takes advantage of both the r-bit and m-bit associated with every page.
Since replacing a modified page is more costly than replacing an unmodified page, the algorithm gives modified pages an additional chance to remain resident.
The third-chance page replacement algorithm, also known as the not-recently-used page replacement algorithm (NRU), is a coarse-grain approximation of LRU, which divides pages into 4 categories based on the 4 possible combination of the r- bit and the m-bit.
At a page fault, the algorithm repeats the following steps until a page is selected for replacement:
If the pointer is at a page p with r = 0 and m = 0 then select p and advance the pointer to the next page.
Otherwise, reset the bits according to the following table, advance the pointer to the next page, and continue the search.
A third bit is needed to remember if a page has been modified and thus needs to be written back to disk when selected for replacement.