Virtual Memory)
The so-called virtual storage technology refers to: when a process is running, it is first loaded into the memory, and the other part is temporarily stored on the disk. When the command to be executed or the accessed data does not exist in the memory, the operating system automatically transfers them from the disk to the memory.
Virtual Address Space-Virtual Memory allocated to the Process
Virtual Address: the location of commands or data in the virtual memory, which can be accessed, as if it is a part of the memory.
Storage hierarchy
Virtual Storage and Storage System
The memory and disk are organically used together to obtain a large "Memory", that is, virtual storage.
Virtual Memory is an abstraction of memory. It is built on the storage system and the operating system coordinates the use of memory.
Virtual storage provides a much larger address space than physical memory.
Address protection
- Ensure that each process has an independent address space
- Make sure that the process accesses a valid address space to prevent the address from being out of bounds.
Note: The base address registers and limit register Operating Systems in are loaded with special privileged commands.
- Make sure that the operations of the process are valid.
Paging)
** Virtual storage technology + Page-based storage management solution
-> Virtual page Storage Management System
Including: 1. Demand paging; 2. prepaging)
Basic Ideas
Before the process starts running, not all pages are loaded. Second, one or zero pages are loaded.
Then, dynamically load other pages according to the process running needs.
When the memory space is full and a new page needs to be loaded, replace a page in the memory according to an algorithm to load the new page.
In fact, it is to exchange CPU time and disk space for expensive memory space, which is the resource Conversion Technology in the operating system.
Design of page table and page table items
Design of page table items
- A page table consists of page table items.
- Page box number, valid bit, access bit, modify bit, protection bit
- Page number (memory block number, physical page number, page frame number)
- Valid bits (resident bits, interrupt bits): indicates whether the page is memory or disk
- Access bit: reference bit
- Modified bit: whether this page has been modified in memory
- Protection space: Read/read/write
In general, the page table item is a hardware design
About page tables
32-bit virtual address space page table size
- If the page size is 4 K and the page table item size is 4 bytes, a process address space has 2 ^ 20 pages, and the page table requires 1024 pages (page table page)
64-bit virtual address space
-The page size is 4 kb. When the page table item size is 8 bytes, the page table size of a process reaches 32,000 TB.
If the page table page is not stored in memory, you need to introduce the address index table of the page table page-> page Directory (page Directory)
Note that the second-level page table can represent 4 GB virtual address space
Introduce reverse (inverted) page table
- Address Translation
Starting from the virtual address space: Virtual Address-> page table-> get the page number-> form a physical address
One page table for each process
- Solution
- Starting from the physical address, the system creates a page table
- Page table items record the ing between a virtual address (Virtual page number) of process I and the page box number.
Storage Model-Based Virtual Storage Technology