官术网_书友最值得收藏!

  • Expert C++
  • Vardan Grigoryan Shunguang Wu
  • 330字
  • 2021-06-24 16:33:57

Virtual memory

The memory consists of lots of boxes, each of which is able to store a specified amount of data. We will refer to these boxes as memory cells, considering that each cell can store 1 byte representing 8 bits. Each memory cell is unique even if they store the same value. The uniqueness is achieved by addressing the cells so that each cell has its unique address in the memory. The first cell has the address 0, the second cell 1, and so on. 

The following diagram illustrates an excerpt of the memory, each cell with its unique address and ability to store 1 byte of data:

The preceding diagram can be used to abstractly represent both physical and virtual memories. The point of having an additional layer of abstraction is the ease of managing processes and providing more functionality than with physical memory. For example, OSes can execute programs greater than physical memory. Take a computer game as an example of a program taking almost 2 GB of space and a computer with a physical memory of 512 MB. Virtual memory allows the OS to load the program portion by portion by unloading old parts from the physical memory and mapping new parts. 

Virtual memory also better supports having more than one program in memory, thus supporting parallel (or pseudo-parallel) execution of multiple programs. This also provides efficient use of shared code and data, such as dynamic libraries. Whenever two different programs require the same library to work with, the single instance of the library could exist in memory and be used by both programs without them knowing about each other. Take a look at the following diagram, which depicts three programs loaded into memory:

There are three running programs in the preceding diagram; each of the programs takes up some space in virtual memory. My Program is fully contained in the physical memory while the Calculator and Text Editor are partially mapped to it.

主站蜘蛛池模板: 东乌| 灵丘县| 凉城县| 沙河市| 桐柏县| 神池县| 安远县| 永康市| 道真| 隆回县| 大兴区| 松潘县| 普兰县| 磐安县| 舞钢市| 汉中市| 马鞍山市| 辰溪县| 高要市| 安塞县| 兴安县| 舟山市| 成都市| 泰兴市| 云霄县| 佛冈县| 当涂县| 花莲市| 新昌县| 和平区| 内黄县| 德江县| 岳阳市| 池州市| 宜宾县| 清丰县| 卢龙县| 天台县| 宁武县| 绥中县| 长丰县|