Virtual Memory Organization | Mapping | Virtual Memory Management Technique - CodeTextPro

In this virtual memory organization tutorial, we wil learn more about - What is Virtual Memory?, Virtual Memory, Virtual Address Space and Memory Space, Virtual Memory Management Technique, Paged memory management technique, Virtual Address Translation, Address Translation Steps, Segmented Memory Management Technique, virtual memory in computer architecture, 



Virtual memory organization, mapping and management techniques


Virtual Memory / What is Virtual Memory?
In a memory hierarchy system, programs and data are first stored in auxiliary memory. Portions of a program or data are brought into main memory as 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 auxiliary memory. It is used to give programmers the illusion that they have a very large memory at their disposal, even though the computer actually has a relatively small main memory.



Virtual Address Space and Memory Space
An address used by a programmer is called a virtual address, and the set of such addresses are called virtual address space. An address in main memory is called a location or physical address. The set of such locations is called the memory space.



Virtual Memory Management Technique
There are various techniques re used to manage virtual memory such as paged memory management technique, segmented memory management technique e.t.c


1. Paged memory management technique
User program is divided into fixed size block called pages while main memory is also divided into same size block called page frame.

Now if a user program is divided into 256 no of pages each of size 4 Kb and main memory is divided into 16 no of pages then CPU must have information which 16 pages among 256 pages is available in main memory. For this purpose a table is maintained for each process in main memory called page map table (PMT).


PMT (Page Map table)

Size of PMT: It is total no of pages in user program. In above case it is 256.


Location of page table in main memory: the start address of PMT in main memory is kept in a register called page table register.




Contents of page table
Each page table entry indicates the page frame where a particular page resides. So the basic structure is Where page index is used to access a particular entry in PMT. Page frame address is the page frame no in main memory where actually the page resides. Valid bit or presence bit indicates whether the page frame contains the page or not i.e. the page is copied into main memory or not. If not then the page is copied from auxiliary memory and corresponding entry is made into PMT.

Virtual Memory Management Technique
Virtual Memory Management Technique


Virtual Address Translation
Let’s consider CPU supports 20 bit address so the virtual address is of 20 bits.


This 20 bits virtual address is divided into two parts

1. Virtual Page number
2. Page offset.

If there are total 256 pages then it needs 8 bits to address one of the virtual addresses. So the remaining 12 bits are page offset which indicates an entry within a page.


Virtual Address Translation
Virtual Address Translation


Virtual Address Translation
Virtual Address Translation


Address Translation Steps:
1. CPU generates 20 bits virtual address.

2. Virtual page number (p) is added with page table register to get page table entry in main memory.

3. Page frame number (f) is fetched from PMT if the present bit is set to 1. Otherwise, page is brought from disk into main memory and makes corresponding entry in PMT.



Problem: We have to access main memory at least twice to get the page. First to get the page frame address from PMT and then to get the page frame.





2. Segmented Memory Management Technique
To eliminate the problems of paging we divided the program into logical entity based on some logical characteristics called segments. For example code segment, data segment or stack segment e.t.c. the size of this segments are not fixed.


Segment:
A segment is a set of logically related instructions or data elements associated with a given name. Segments may be generated by the programmer or by the operating system. Examples of segments are a subroutine, an array of data, a table of symbols, or a user's program.


Segmented Memory Management Technique
Segmented Memory Management Technique

Address Translation
Assumption: No paging in the system.

The steps are

1. CPU generates logical addresses.

2. These addresses consist of a segment number and an offset into the segment


3. Use segment number to index into a table called segment descriptor table. 

  • Segment descriptor table contains the physical address of the start of the segment called the base address.

4. Add the offset to the base address and generate the physical address.
  • Before doing this, check the offset against a limit.
  • The limit is the size of the segment.

Virtual Memory Address Translation
Virtual Memory Address Translation



Post a Comment

1 Comments