MMU needs to be used at a cost, which is reflected in memory, system power consumption, and development complexity. Let me take a look at the memory cost.
The arm system can have two virtual address segmentation methods: two segments and three segments. The split of two segments uses 1 MB as the page (also called Section). In the split of three segments, the page size can be 1 kb, 4 kb, and 64 KB. We will discuss it in 4kb.
During the 4 kb address conversion process, the virtual address is divided into three segments, each of which has 12 bits, 8 bits, and 12 bits (32 bits in total ).
As we all know, each process has an independent page table. That is to say, the memory used as a page table in the whole system is equal to the total memory occupied by the page tables of all processes. How much memory does each process occupy as a page table? Theoretically, each process can access a 4 GB address space. If the process can access any address in the 4 GB space at any time, all the page tables should be in the memory. In this calculation, the memory consumed by the process on the page table is 16 KB (conversion table) + 4096 * 1kb (rough page table) = 4112kb. In this case, if there are dozens of processes in the system, the memory consumption is terrible!
However, this is a theoretical discussion. In fact, each process does not have 4 GB of access space. The operating system usually divides the address space into several blocks. For example, Linux uses the low-end 3 GB memory space for applications.ProgramProcess (called user space), while the high-end 1 GB space is left to the operating system itself (called system space ). In this way, the page table consumption of each process is greatly reduced! In addition, the memory required by the page table is not allocated when the process is loaded, but is allocated and filled with configuration by the operating system when a page error occurs. Therefore, the page table memory used for a process depends on the memory space span accessed by the process.
well, it seems to be nonsense, but these nonsense will make people understand the fact: in the process of converting a virtual address to a physical address, hardware is required to complete a series of table queries, and these page tables all consume memory! For embedded systems, especially systems that care about the cost, this is very expensive, so MMU is not enough, although it is very nice to remember.