seegongsik
Operating systems

What is memory protection

In lesson 9 on virtual memory, we saw that each program has its own memory and can't even see anyone else's. But in fact, everyone's data is mixed together in one real memory. So what stops programs from touching each other's things? Surprisingly, there's no wall blocking them.

01

Many living mixed together in one memory

From the fake view, each seems to have its own space, but inside real memory everyone is mixed together. A's pieces and B's pieces sit side by side.
If A could touch B's space right next to it, a single mistake by A could wreck B, and A could even peek at B's secrets.

Real memory
A
B
A
B
B
A
A
B
A
B
B
A

In real memory, pieces of A (gold) and B (blue) sit mixed together.

Mixed together in one space like this, it looks risky. But in reality, A can never touch B.
Is some sturdy partition standing between them? No. The secret lies in the map we saw in lesson 9.

02

Not a wall, just no road

Think back to the map from lesson 9. A's map points only to A's real spaces, and there's no road at all on it leading to B's space.
So A has no way even to name "B's address."
It isn't that a wall separates them; there's simply no road to take.

A map
A1
✓
B1
no path
A2
✓
B2
no path
A3
✓

Choose A: A's map leads only to A's spaces, and there's no arrow to B.

With no road on the map, there's no way to get there. But what happens if a program, by mistake or on purpose, calls an address outside its map?
Then another safety device kicks in.

03

Try to cross the line, and you're caught

When a program calls an address that isn't on its map, there's no real space to translate it to, so the translation fails.
At that instant, the hardware notices and alerts the operating system, which says "You touched a space that isn't yours" and stops just that one program.
The bad access never reaches its target.

Try A's address and B's address in turn: yours goes through (green), someone else's is caught and stopped (red).

Yours went through, and the other was caught on the spot. Attempts to cross the boundary never succeed.
This brings a very reassuring result: even if one program breaks down, the damage doesn't spread to others.

04

One breaks, the rest are fine

Because each program is confined to its own section, a program that breaks down can only mess up its own space. It can't touch other programs' memory or the operating system.
The operating system quietly cleans up just that one broken program, and the rest carry on as if nothing happened.

P1
running
P2
running
P3
running

Break one program: only that one stops, and the rest keep running.

Without protection, the one broken program would have dragged everything down with it. Keeping them apart kept the accident in one section.
Stability and security both come from here, and underneath them is not a "wall" but "separate maps."

05

Separation is protection

To sum up, memory protection isn't a wall built separately. Because each process gets its own map, there's no road to one another, and anything that tries to cross the line is caught and only that one stops.
So they can live mixed together without colliding, and one breaking down doesn't spread. Keeping them separate is itself the protection.

Turn protection off and on to see the difference: on, an accident stays in one section; off, it spreads to everything.

So far the operating system has managed the CPU and memory from the inside: letting programs take turns (time-sharing, scheduling) and keeping them apart (virtual memory, protection).
But a computer also has to talk to the outside world: the keyboard, the screen, the disk, and even brand-new devices it has never seen.
How does the operating system recognize all those devices? That's the next story.

In one lineMemory protection isn't a wall blocking the way; it's what results from each process having a different map. Your map points only to your spaces, so there's no road to anyone else's in the first place. If a program tries to cross the line, the address isn't on its map, so the hardware catches it and the operating system stops just that program. That's why, even if one breaks down, the rest are fine. Separation is protection.
← Operating systems
Was this helpful? Support seegongsik