For each process, it requires a certain size of (physical) memory (DRAM) at run time, and one of the simplest methods is how much memory the process needs to "preempt" the large (physical) memory. To give a simple example, assuming that the memory size of a computer is 128MB, process A, B, C runtime need 100MB, 10MB, 30MB of memory, if according to a, B, C Run order, then process a runtime preemption 100MB memory, process B needs 10MB, then process A, B can run at the same time, when process C needs to run, because the system memory space is only 18MB left, not enough process C to run, then the system needs to terminate process A and release process A's memory for process C to run, its simplified icon is as follows.
Here are a few things we can see
(1) The memory between different processes is not necessarily continuous;
(2) If process C is a malicious process, it can access (for example, pointers) process B in some way and destroy it.
There are several drawbacks to this kind of memory management, first, in the case of memory constraints, if there is a large memory-intensive process, you need to make large-scale memory release so that the process can run, and secondly, in physical memory, the different processes are "visible", That is, a process can "access" other processes in some way, which creates a tremendous degree of insecurity. Virtual memory/Virtual storage can be said to solve the above problems, and become an important mechanism of operating system memory management. Compared to the direct "preemption" of physical memory, it provides a large, contiguous, and private, "virtual" storage space-virtual memory-on disk for each process. At the same time, this virtual memory is divided into "small pieces", when running to this part of the time to swap it to physical memory, the specific principle will be discussed later.
Here is a small summary: virtual memory (VM) can be said to be an important mechanism of operating system memory management, providing a large, consistent and private address space for the process, providing several important capabilities:
(1) It regards main memory (DRAM) as the cache of the address space stored on disk;
(2) Provide a consistent address space for each process;
(3) Protection of each address space is not destroyed by other processes.
Actually speaking so much, the most important thing is such a process. When we create a process, the operating system assigns us a virtual memory
[CSAPP9] Virtual Storage/virtual Memory/VM Learning notes