Simple summary of virtual memory

来源:互联网 发布:哪里可以买淘宝店铺 编辑:程序博客网 时间:2024/06/04 19:38

Search some materials on the internet and books. Review the knowledge and make a simple summary.

1 Virtual memory

Virtual memory is a memory managementtechnology for modern multitasking operating system. Processes do not get thephysical memory directly. Each process runs on its own virtual memory which is automaticallytranslated into real memory by operating system and hardware.

The application program thinks it has alarge range of continuous address space. In reality, the parts it is currentlyusing are scattered around the RAM, and the inactive parts are saved in harddisk. No matter how much the physical memory is in a computer, the amount ofvirtual memory space in a 32 bit system is always 4GB.

 

The virtual address space starts at zero.It is composed of many fixed size pages. It includes Text, Data, BSS, Heap, andStack at least. The heap and stack can shrink or grow.

 

A simple example

 

char courty = “China”; [global var. “China”is Text and read-only data]

int prvNum; [Not initialized, BSS]

char * fun(void){

char * p; [localvar; Stack]

prvNum = 33;

p = malloc(prvNum);[Heap;dynamic memory]

return p;

}

 

2. page


Page is a fixed-length block of mainmemory. It is continuous in both physical memory addressing space and

 

virtual memory addressing space. A page isusually the smallest unit of data for the following:

 1.Memory allocation performed by the operating system for a program

 2.transfer between main memory and any other auxiliary store.

 

Two-level page table structure

 There are many sub tables that cover all the virtual address space. Amaster table convers all sub tables. An address refers to the master table. Thevirtual address is divided into three parts. See the next picture. Using multi-level page table structureaccelerates the searching speed. I call the idea as classification.

 

Otherexamples: army organization; a book content table and contents.

 

Reference:

http://en.wikipedia.org/wiki/Dynamic_memory_allocation

http://members.shaw.ca/bsanders/WindowsGeneralWeb/RAMVirtualMemoryPageFileEtc.htm

http://www.cs.princeton.edu/courses/archive/spr04/cos217/lectures/Memory.pdf

 

原创粉丝点击