Virtual Memory (week 9) Flashcards
where is virtual memory of the computer
it is on the fast secondary memory (hard disk) of your computer
why is sole use of primary memory not enough to run programs
–> Because large portions of most programs are not executed most of the time.
–> Therefore, large portions of programs need not be in memory.
–> Need to maximize the use of primary memory by loading as many programs as possible so as to increase CPU utilization.
what is virtual memory and what does it do ?
–> Virtual memory allows the execution of
processes that are not completely in memory
–> Each process’s address space is partitioned into parts that can be loaded into primary memory
–> Partitions which are not needed are written to secondary memory
–> Allows program that are larger than physical memory to be executed
Every process has code and data ______
locality
when is there a change in locality
As computation moves to a different
phase there is a change in locality
how is the address space partitioned
Address space is logically partitioned
–> Text, data, stack
–> Initialization, main, error handle
how is virtual memory organized
for example if there is 2 parts of a program (Pi) which is part A and part B first the part A will be loaded into primary memory and after part A has been executed it will be sent back to virtual memory and part B will loaded into primary memory.
why is there a need to implement an additional layer of abstraction for virtual memory
An additional layer of abstraction is implemented to map the physical addresses of data stored in RAM to virtual memory addresses that can be used by the OS
.
.
To support virtual memory, the computer
system needs to manage memory in _______
blocks
Virtual memory system transfers “blocks” of
the address space to/from _______
primary memory
what are the 2 types of blocks
Fixed size blocks (paging)
Variable size blocks (segmentation)
what is the commercially dominant form of virtual memory today ?
demand paging
what is fixed size block s
System-defined pages are moved back and forth between primary and secondary memory
what is variable size blocks
Programmer-defined segments - corresponding to logical fragments – are the unit of movement
what is a page
A page is a fixed size, 2^h, block of virtual
addresses, where h is an integer
what is a page frame
A page frame is a fixed size, 2^h, block of
physical memory (the same size as a page)
why is the size of a page exponent of 2
to minimize translation time between virtual and physical addresses
what happens in demand paging
–> In demand paging, the pager brings the necessary pages into memory.
–> Avoids reading in memory pages that will not be used, decreasing the swap time and the amount of physical memory needed.
–> In a pure demand paging scheme, the system never bring a page into the memory until it is needed.
what are the benefits of using virtual memory
–> Programs no longer constrained by the
amount of physical memory
–> Each program takes less physical memory, allowing more to run at the same time, increasing CPU utilization/throughput
What happens when a page is required
but that page is not in memory but in the
virtual memory?
page fault occurs
what is a page fault
A page fault is an event when a page is
required but is not found in the primary
memory, but is in virtual memory
what is a page table
Page table is a hardware mechanism implemented to map the logical page of the program to the physical page frame where the page is loaded.
what is the valid-invalid scheme
The valid-invalid scheme is used to
distinguished between those pages that are in memory and those that are on the disk.
what does it mean if the table has bit 0/1
–> Each page table entry is associated with a bit (1 - in memory, 0 - not in memory).
–> If the bit is set to “valid”, the page is both legal and in memory. Otherwise, the page is either not valid or is valid but is on disk.
–> Access to page marked invalid causes a pagefault trap.
what is the page fault rate
Page Fault Rate 0 ≤ p ≤ 1.0
if p = 0 no page faults
if p = 1, every reference is a fault
what is Effective Access Time (EAT)
shows performance of demand paging
EAT = (1 – p) x memory access time
+ p (page fault overhead
+ [swap page out ]
+ swap page in
+ restart overhead)
avg page service fault time = page fault overhead + [swap page out ] + swap page in + restart overhead
EAT is directly proportional to ____________
page-fault rate
what is page replacement
When a computer needs to access a page that is not currently in RAM, it must first find a page to remove from RAM to make space for the new page.
This process is known as page replacement. The computer uses an algorithm to determine which page to remove, with the goal of minimizing the number of page faults.
when is the page fault very high
If a process does not have “enough” pages
when is a process thrashing
A process is thrashing if it is spending more time paging than execution.
–> The CPU utilization is low.
–> The operating system thinks that it needs to increase the degree of multiprogramming.
how can the effects of thrashing be limited
by using locality replacement algorithm
why does trahsming occur
Σ size of locality > total memory size (running too many programs at the same time)
why does paging work in limiting thrashing occurrences
because of the Locality model
–> Process migrates from one locality to another.
–> Localities may overlap (more efficient use of its available RAM.)