Home  >  Article  >  Operation and Maintenance  >  Why does linux need mmu

Why does linux need mmu

WBOY
WBOYOriginal
2022-08-17 17:45:262603browse

Because mmu can be used to provide support for virtual memory management; mmu is the abbreviation of "Memory Management Unit". It is the control circuit used in the central processor to manage virtual memory and physical memory. It is also Responsible for mapping virtual addresses to physical addresses and providing hardware mechanisms for memory access authorization.

Why does linux need mmu

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Why does linux need mmu

Because modern operating systems generally adopt a virtual memory management (Virtual Memory Management) mechanism, which requires the support of the MMU (Memory Management Unit) in the processor. .

MMU (Memory Management Unit): Memory Management Unit, which is the control circuit used in the central processing unit (CPU) to manage virtual memory and physical memory. It is also responsible for mapping virtual addresses to physical addresses and providing Hardware mechanism for memory access authorization.

The main function of the memory management unit (MMU) is the conversion of virtual addresses (virtual memory addresses) to physical addresses (physical addresses). In addition, it can also implement memory protection, cache control, bus arbitration and bank switching.

Working mechanism

Why does linux need mmu

The CPU passes the requested virtual address to the MMU, and then the MMU first The cache TLB (Translation Lookaside Buffer) searches for the translation relationship. If the corresponding physical address is found, it is accessed directly; if it is not found, it is searched and calculated in the address translation table (Translation Table).

Virtual address

The modern memory management unit partitions the virtual address space (the range of addresses used by the processor) in pages. The page size is 2 to the nth power, usually a few KB. So the virtual address is divided into two parts: virtual page number and offset.

Why does linux need mmu

Page table entry

The entry that stores the physical page table number found in the page table from the virtual page number above is the page table Item(PTE). PTE generally occupies 1 word in length, which contains not only the physical page number, but also the rewrite flag bit (dirty bit), access control bit (accessed bit), the process type that allows reading and writing (user/supervisor mode), and whether Can be cached and mapped (last two digits of PTE).

Mapping

Mapping method

There are two mapping methods, segment mapping and page mapping. Segment mapping only uses the first-level page table, and page mapping uses the first-level page table and the second-level page table.

Mapping granularity

There are two mapping granularities for segment mapping, 1M section and 16M supersection; mapping granularities for page mapping include 4K small page, 64K large page and the outdated 1K tiny page.

Why does linux need mmu

Recommended learning: Linux video tutorial

The above is the detailed content of Why does linux need mmu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn