Session 3: Virtual Memory

Posted on 5 mins

Session Operating Systems Virtual Memory

Intro

Session 3 ran on Thursday, 8th October in AT7.14. The session covered an exploration into Virtual Memory, why it’s needed because of problems with Physical Memory, and some talk about Paging. This session was ran by Kacper and Archie.

NOTE: This session wasn’t best-prepared due to us having other commitments (mostly academics), so we do apologise that this content is probably not the best / up to par with previous sessions.

Session Content + Resources

Session Slides (Click Me!) Session slides were made with content generally available on the internet + some content from Operating System Concepts 10th Edition (2018) by A.Silberschatz (especially the nice diagrams).

Physical Memory

Address Spaces & User Processes

How do user processes actually get to use memory? What tells us where one process’ memory region ‘starts’ and ’ends’? The Operating System, running in kernel mode (needs to use privileged CPU instructions), manages base and limit registers for different processes. These indidcate where a process’ memory block starts (i.e. at the base), and where it ends (at the base + limit).

Base and Limit Registers in Action - from A . Silberschatz’ Operating System Concepts

The base and limit registers should only be modifiable by the Operating System. If any user process was able to edit its own base and limit registers, let alone the base and limit registers of other processes, you could get malicious processes trying to overwrite other memory locations or accessing memory they shouldn’t be.

Some useful-to-know terminology + concepts

Relocation Register in the MMU - from A . Silberschatz’ Operating System Concepts

Limitations of Physical Memory

Introducing Virtual Memory

So, we need something to fix all of those limitations. Luckily, some really smart people came up with Virtual Memory which is the holy grail to solving those issues. The key ideas we’ll focus on are what solves our limitations:

  1. Uses a concept known as paging to move data between RAM and Disk, effectively extending the size of our memory massively (in fact, it can be said that virtual memory size is infinite, though this is mainly due to a very large virtual address space).
  2. We effectively treat RAM & Disk like a cache; inactive programs tend to get their memory put away onto the disk and they only get it fetched if we tab back in (i.e. tabbing in and out of a user program).
  3. Isolates user processes’ memory spaces into their own, secure areas so that we can stop worrying about a malicious process accessing other processes’ memory.

Slightly more detail:

Paging

Paging write-up to be done later, sorry for inconvenience!

x86_64 4 level Paging from CPULand

End of Post

If you have any questions, join our discord and ask away!

42 49 54 53 49 47 20 3C 33 20 59 4F 55