Physical memory and virtual memory

Physical memory (memory): When a program is opened, the system will be loaded into the physical memory.

Virtual memory (hard disk): virtual than physical memory, but instead of exercising physical memory storage function, the function of physical memory to run the program is unable to use virtual memory to complete.

The relationship between physical memory and virtual memory: when too many programs running, the physical memory is not enough, the system will be part of hard disk space as memory usage, this part of the space is the virtual memory.

 

The reason the birth of virtual memory: processes running on the system to share the CPU and main memory resources, when too many running processes, limited resources and too much main memory main memory demand will cause conflicts, there will be saturation value. Causing some process does not work, but the memory is still very easy to make mistakes, when a process writes the contents of the memory space of another process, the error will cause unknown.

In order to better manage memory resources, the virtual memory must be provided for each process a large (ensure that the process can successfully run), consistent (we should need to run the process without discrimination) and private (not ensure a different process accidentally written into another storage space of a process that caused the error) storage space. This virtual memory must have three main functions:

The main memory as a cache memory address space on a disk, save only the active area in the main memory, and transfer data back and forth in the disk and main memory on demand (in main memory only saves the running process information, although I feel like all processes at the same time, but in fact this is just the CPU to quickly switch between processes illusion, CPU processing at a time only one event. Therefore, when the CPU switch from one process to another, if memory the lack of space, he will first part of the contents removed, the current process of loading new information available, it said main memory is stored in the address space on the disk cache)
that provides a consistent address space for each process, simplifying memory management (we do not need to consider the data and code need to use specific on what memory address, the address mapping will be achieved through certain mechanisms, the address space of all processes are start from 0 address)
which protects every the address space of a process is not destroyed by another process

 

 

https://blog.csdn.net/FreeeLinux/article/details/53783039

https://www.cnblogs.com/ideawu1001/archive/2013/07/22/3204820.html

https://blog.csdn.net/gong_1/article/details/18405153

Guess you like

Origin www.cnblogs.com/yangxingsha/p/11362190.html