Is the MMU inside of Unix/Linux kernel? or just in a hardware device with its own memory?

So i always thought MMU is part of the unix kernel that translates addresses to physical addresses but in the MMU wiki page it says its a computer hardware that usually have its own memory, but that page doesn’t talk much about Unix/Linux operating systems

So I’m confused, does the all the translation happen in hardware and kernel doesn’t do any translation? and basically the operating system doesn’t know anything about the real physical address?

I’m asking about Unix based operating systems, but if you know about other operating systems as well like windows or if its a general thing in modern computers let me know, thanks.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The MMU (memory management unit) is a physical component of the computer system, typically part of the CPU (but not necessarily). It translates virtual addresses (also known as linear addresses in the x86 world) to physical addresses; it can also enforce memory access control, cache control, and bus arbitration. It doesn’t usually have its own memory, it relies on data in the system’s main memory to operate.

The MMU performs this translation by using information stored in data structures such as page tables; these specify which physical address ranges correspond to linear address ranges (if any — a page can be “not present”). The page tables are set up by the kernel, and the kernel determines what the mappings should be — so the ultimate authority on physical addresses is the kernel, however it always operates with the help of the MMU. Put another way, the CPU always operates on linear addresses, which are translated to physical addresses by the MMU, but the kernel is aware of the translations and programs the MMU to perform them.

User-space processes are oblivious to all this and aren’t (normally) aware of the physical addresses corresponding to the linear addresses they use, and typically can’t access the mappings either. There are some cases where physical mappings leak, but those are usually considered to be security vulnerabilities and quickly addressed. However, in Linux, processes with sufficient privileges can see their physical map in /proc/<pid>/pagemap.

For Linux specifically, see the memory management documentation, and in particular the section on examining page tables.

Method 2

The Memory Management Unit (MMU) is a piece of hardware that translates virtual addresses to physical addresses. For example, when the CPU emits an address to read, the MMU translates that virtual address to a physical address and then emits the physical address to the memory bus.

The MMU is programmed by the operating system. The operating system manages memory (both physical and virtual) and manages the virtual-to-physical mapping.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x