Virtual memory refers to a software design technique used to provide users with larger random access space in computers with insufficient memory capacity.
The virtual memory system refers to the program that manages and allocates virtual memory for user programs. (Recommended learning:phpstorm)
The reasons for the emergence of the virtual memory system are the small memory capacity and the principle of program locality.
Paging management: Divide the memory into fixed-size pages and allocate several pages to load the entire process. An important advantage is that pages can be discontinuous. It does not produce external fragmentation and uses memory more effectively. However, it will produce some internal fragmentation. That is, the last page allocated to the process often cannot be used up exactly. However, when the page size is not very large, acceptable.
Demand paging and virtual memory
Demand paging: Put the process into virtual memory, because the pages of a process will not all be used at the same time To, only the pages that need to be used are transferred into physical memory.That is, the entire process is not in physical memory.
Several concepts of requested paging: (Blog link: Memory allocation in requested paging)
Fixed allocation: allocated to the process in physical memory The number of memory blocks is certain.
Variable allocation: Physical memory is first allocated to some memory blocks of the process. If it is not enough, it can be increased appropriately.
Partial replacement: When the allocated memory block is used up and a page fault occurs, you can only replace your own memory block.
Global replacement: When the allocated memory block is used up and a page fault occurs, it can be replaced with a free page reserved by the operating system. This is actually equivalent to increasing the number of memory blocks occupied by the process.
Three allocation methods: fixed allocation local replacement, variable allocation global replacement, variable allocation local replacement. Fixed allocation and global replacement cannot be combined.
The above is the detailed content of About paging and virtual memory in the operating system. For more information, please follow other related articles on the PHP Chinese website!