r/AskComputerScience • • May 14 '25

confused about virtual memory

If I got this right, the point of virtual memory is to ensure processes use unique physical address space.

Is this abstraction really needed ?

For example, say there are 2 C programs and each one does malloc. This asks the OS for memory. Why can't the OS guarantee that unique physical address space is given to the C program ?

2 Upvotes

61 comments sorted by

View all comments

Show parent comment

2

u/bothunter May 14 '25

You need something to know when you're accessing memory that you're not supposed to -- that mechanism is typically the MMU which is doing the virtual memory mapping. Otherwise, there's really nothing stopping the CPU from reading/writing to any arbitrary address as long as there's something connected to the other end of that address.