关闭

Simple summary of virtual memory

660人阅读 评论(0) 收藏 举报

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

1 Virtual memory

Virtual memory is a memory management technology for modern multitasking operating system. Processes do not get the physical memory directly. Each process runs on its own virtual memory which is automatically translated into real memory by operating system and hardware.

The application program thinks it has a large range of continuous address space. In reality, the parts it is currently using are scattered around the RAM, and the inactive parts are saved in hard disk. No matter how much the physical memory is in a computer, the amount of virtual 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, and Stack 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; [local var; Stack]

prvNum = 33;

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

return p;

}

 

2. page


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

 

virtual memory addressing space. A page is usually 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. A master table convers all sub tables. An address refers to the master table. The virtual address is divided into three parts. See the next picture. Using multi-level page table structure accelerates the searching speed. I call the idea as classification.

 

Other examples: 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

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:52108次
    • 积分:911
    • 等级:
    • 排名:千里之外
    • 原创:36篇
    • 转载:3篇
    • 译文:0篇
    • 评论:12条
    文章分类
    最新评论