0% found this document useful (0 votes)
57 views15 pages

Advanced Computers Architecture Virtual Memory: Rohit Khokher

The document discusses virtual memory and its implementation. It covers: 1. The key principles of virtual memory including separating logical and physical memory addresses and using secondary storage to augment main memory. 2. Different virtual memory techniques like paging, segmentation, and their combination. 3. Considerations for implementing virtual memory including address translation using page tables, handling page faults when pages are not in memory, and the role of the operating system in memory management.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views15 pages

Advanced Computers Architecture Virtual Memory: Rohit Khokher

The document discusses virtual memory and its implementation. It covers: 1. The key principles of virtual memory including separating logical and physical memory addresses and using secondary storage to augment main memory. 2. Different virtual memory techniques like paging, segmentation, and their combination. 3. Considerations for implementing virtual memory including address translation using page tables, handling page faults when pages are not in memory, and the role of the operating system in memory management.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Advanced Computers Architecture

Virtual Memory

By
Rohit Khokher

Department of Computer Science, Sharda University, Greater Noida, India

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Topic s of my Talk

1. Principles of Virtual Memory


2. Implementations of Virtual Memory
– Paging
– Segmentation
– Paging With Segmentation
– Paging of System Tables
– Translation Look-aside Buffers
3. Memory Allocation in Paged Systems
– Global Page Replacement Algorithms
– Local Page Replacement Algorithms
– Load Control and Thrashing
– Evaluation of Paging

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Hardware and Control Structures

• Memory references are dynamically translated into physical addresses


at run time
– A process may be swapped in and out of main memory such that it
occupies different regions

• A process may be broken up into pieces that do not need to located


contiguously in main memory

• All pieces of a process do not need to be loaded in main memory during


execution

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Execution of a Program

• Operating system brings into main memory a few pieces of the program

• Resident set - portion of process that is in main memory

• An interrupt is generated when an address is needed that is not in main


memory

• Operating system places the process in a blocking state

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
• Piece of process that contains the logical address is brought into main
memory
– Operating system issues a disk I/O Read request

– Another process is dispatched to run while the disk I/O takes place

– An interrupt is issued when disk I/O complete which causes the


operating system to place the affected process in the Ready state

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Advantages of
Breaking up a Process

• More processes may be maintained in main memory


– Only load in some of the pieces of each process

– With so many processes in main memory, it is very likely a process will


be in the Ready state at any particular time

• A process may be larger than all of main memory

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Types of Memory

• Real memory
– Main memory

• Virtual memory
– Memory on disk
– Allows for effective multiprogramming and relieves the user of tight
constraints of main memory

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Virtual Memory

Virtual memory is a technique that allows processes that may not be entirely in the
memory to execute by means of automatic storage allocation upon request.

The term virtual memory refers to the abstraction of separating LOGICAL memory--


memory as seen by the process--from PHYSICAL memory--memory as seen by the
processor. Because of this separation, the programmer needs to be aware of only the
logical memory space while the operating system maintains two or more levels of
physical memory space.

The virtual memory abstraction is implemented by using secondary storage to augment


the processor's main memory. Data is transferred from secondary to main storage as and
when necessary and the data replaced is written back to the secondary storage according
to a predetermined replacement algorithm.

If the data swapped is designated a fixed size, this swapping is called paging; if variable
sizes are permitted and the data is split along logical lines such as subroutines or
matrices, it is called segmentation. Some operating systems combine segmentation and
paging.

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
The diagram illustrates that a
program generated address 

( 1 ) or "logical address" consisting


of a logical page number plus the
location within that page (x) must
be interpreted or "mapped" onto
an actual (physical) main memory
address by the operating system
using an address translation
function or mapper 
( 2 ). If the page is present in the
main memory, the mapper
substitutes the physical page frame
number for the logical number 
( 3 ). If the mapper detects that the
page requested is not present in
main memory, a fault occurs and
the page must be read into a frame
in main memory from secondary
storage 

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Assignment

What do you think are the main


considerations in implementing this virtual
memory system?

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
A System with Physical Memory Only

• Examples:
– most Cray machines, early PCs, nearly all
embedded systems, etc. Memory

0:
Physical 1:
Addresses

CPU

N-1:

Addresses generated by the CPU point directly to bytes in physical memory

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
A System with Virtual Memory
• Examples:
Memory
– workstations, servers, modern PCs, etc.
0:
Page Table 1:
Virtual Physical
Addresses 0: Addresses
1:

CPU

P-1:
N-1:

Disk

Address Translation: Hardware converts virtual addresses to physical


addresses via an OS-managed lookup table (page table) 12

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
Page Faults (Similar to “Cache Misses”)

• What if an object is on disk rather than in memory?


– Page table entry indicates virtual address not in memory
– OS exception handler invoked to move data from disk into memory
• current process suspends, others can resume
• OS has full control over placement, etc.

Before fault After fault


Memory
Memory
Page Table
Virtual Physical Page Table
Addresses Addresses Virtual Physical
Addresses Addresses
CPU
CPU

Disk
Disk
13
C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT
IWW2 2010, ISATANBUL, TURKEY
Mapper

The mapper is the part of the operating system


that translates the logical page
number generated by the program into the
physical page frame number where the main
memory holds the page.

This translation is accomplished by using a


directly indexed table called the page
table which identifies the location of all the
program's pages in the main store.

If the page table reveals that the page is, in


fact, not resident in the main memory, the
mapper issues a page fault to the operating
system so that execution is suspended on the
process until the desired page can be read in
from the secondary store and placed in main
memory.

C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT


IWW2 2010, ISATANBUL, TURKEY
C SINGH, JUNE 7-8, 2010Advanced Computers Architecture, UNIT
IWW2 2010, ISATANBUL, TURKEY

You might also like