Wednesday 29 December 2021

Virtual Memory

In a memory hierarchy system, programs and data are first stored in secondary memory. Portion of a program or data are loaded into main memory when they are needed by the CPU. Virtual memory is a concept used in some large computer systems that permit the user to construct programs as though a large memory space were available, equal to the totality of secondry memory.

Each address that is referenced by the CPU goes to an address mapping from the so-called virtual address to a physical address in main memory. 

A virtual memory system provides a mechanism for translating program-generated addresses into correct main memory locations. 

 This is done dynamically, while programs are being executed in the CPU. The translation or mapping is handled automatically by the hardware by means of a mapping table.

Address space memory space:

virtual address is the address seen by the programmer, and the set of such addresses is called address space. An address in main memory is called physical address. The set of such locations is called the memory space. Thus the address space is the set of addresses generated by programs as they reference instructions and data. The memory space consists of the actual main memory locations directly addressable for processing. In most computers the address and memory spaces are identical.

In multiprogram computer system, programs and data are transferred to and from secondary memory and main memory based on need of the CPU. Suppose the program 1 is currently being executed in the CPU. Program 1 and a portion of its associated data are moved from secondary memory into main memory. Portions of programs and data need not be in contiguous locations in memory because information is being moved in and out, and empty memory locations may be available in different locations in memory. 

In our example, the address field of an instruction code will consist of 20 bits but physical memory addresses must be specified with only 15bits. Thus CPU will reference instructions and data with a 20-bit address, but the information at this address must be taken from physical memory because access to auxiliary storage for individual words will be prohibitively long.

A table is then needed, as shown in below, to map a virtual address of 20 bits to a physical address of 15bits.

Address Mapping Using Pages: 

The physical memory is broken down into groups of equal size called blocks.The term page refers to groups of address space of the same size.The programs are also considered to be split into pages. Page size must be equal to the frame size.

The organization of the memory mapping table in a paged system. The memory-page table consists of eight words, one for each page. The address in the page table denotes the page number and the content of the word gives the block number where that page is stored in main memory. A presence bit in each location indicates whether the page has been transferred from secondary memory into main memory. A 0 in the presence bit indicates that this page is not available in main memory. The CPU references a word in memory with a virtual address of 13 bits. The three high-order bits of the virtual address specify a page number and also an address for the memory-page table.   

The content of the word in the memory page table at the page number address is read out into the memory table buffer register. If the presence bit is a 1, the block number thus read is transferred to the two high-order bits of the main memory address register. The line number from the virtual address is transferred into the 10 low-order bits of the memory address register.



A read signal to main memory transfers the content of the word to the main memory buffer register ready to be used by the CPU. If the presence bit in the word read from the page table is 0, it signifies that the content of the word referenced by the virtual address does not reside in main memory. A call to the operating system is then generated to fetch the required page from auxiliary memory and place it into main memory before resuming computation.

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top