user1764917
user1764917

Reputation:

Virtual memory and memory management unit

Why do we need the memory management unit?

It seems the only task of the memory management unit is to convert virtual addresses to physical address. Can't this be done in software? Why do we need another hardware device to this?

Upvotes: 0

Views: 544

Answers (2)

user3344003
user3344003

Reputation: 21607

The reason for a MMU component of a CPU is to make the logical to physical address translation transparent to the executing process. Doing it in software would require stopping to process every memory access by a process. Plus, you'd have the chicken and egg problem that, if memory translation is done by software, who does that software's memory translation.

Upvotes: 0

Claudio
Claudio

Reputation: 10947

MMU (Memory Management Unit) is a hardware component available on most hardware platforms translating virtual addresses to physical addresses. This translation brings the following benefits:

  • Swap: your system can handle more memory than the one physically available. For example, on a 32-bit architecture, the system "sees" 4 GB of memory, regardless of the amount of the physical memory available. If you use more memory than actually available, memory pages are swapped out onto the swap disk.
  • Memory protection: the MMU enforces memory protection by preventing a user-mode task to access the portion of memory owned by other tasks.
  • Relocation: each task can use addresses at a certain offset (e.g., for variables), regardless of the real addresses assigned at run-time.

It is possible to partially implement a software translation mechanism. For example, for the relocation you can have a look at the implementation of gcc's fpic. However, a software mechanism can't provide memory protection (which, in turn, affects system security and reliability).

Upvotes: 1

Related Questions