View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

Lecture 9

Virtual Memory

Lecture

Slides (PDF, PPTX).

Outline

Workshop

Tasks

  1. Consider a virtual memory system that can address a total of 250 bytes. You have unlimited hard drive space, but are limited to 2 GB of semiconductor (physical) memory. Assume that virtual and physical pages are each 4 KB in size.
    • How many bits is the physical address?
    • What is the maximum number of virtual pages in the system?
    • How many physical pages are in the system?
    • How many bits are the virtual and physical page numbers?
    • How many page table entries will the page table contain?

TODO

Examples:

Homework

  1. Programming task “PseudoVM”.

Write an exception handler that imitates “virtual memory” for “forbidden” addresses. A “forbidden” address is any address that causes exceptions LOAD_ACCESS_FAULT and STORE_ACCESS_FAULT when we try to access it (read or write). This is not supported for address 0x0 (it is reserved).

Memory configuration

It is suggested to create a table (array) that will store records "virtual address":value (pairs of 4-byte values). The capacity of the table is 16 records (i.e. 2*4*16=128 bytes). Address 0x0 can be used to specify an empty record.

“Virtual memory” works only with instructions lw and sw that use register t0 as a source/destination for values (other registers are not checked).

Reading from an address works in the following way:

Writing to an address works in the following way:

Notes:

Input:

21
123
22
1234
20
1001
100500
1000
100
-70001
-70001
-70000
-70004
0

Output:

1234
100500
0
0
-70001

References