This homework contains practice for thinking about virtual memory, which you will need in the remainder of the class. So you should totally work through the problems carefully even though, as usual, we're not going to grade these strictly.
Scheduling
This question is open-ended; there are many possible answers. You don't have to type very much, and you can think about these questions even when you are not in front of a computer.
There are many metrics that a scheduler has to balance: turnaround time, response time, throughput, and various definitions of fairness. We will consider the following types of systems in this question:
- A high-performance computer used for large number crunching tasks (genetic sequencing, graphics rendering...)
- A multimedia computer (video games, movies...)
- A smartphone
- A general-purpose computer on a corporate desktop
- For each of the system types above, which metrics do you think are the most important, and why? Some things to consider: How many users does the system have? Are user processes typically interactive? How long is a user willing to wait? What frustrations will users have if certain metrics are ignored? (There are many possible answers to this question.)
- Taking into consideration your answers above, propose a scheduling policy (FIFO, etc.) for each system above.
- For each of the systems above, what is the scheduling policy that would most completely undermine the purpose of the system?
Virtual memory: warmup
This question is borrowed from CS:APP3e [Computer Systems: A Programmer’s Perspective (Third Edition), by Randy Bryant and David R. O’Hallaron].
Complete the following table, filling in the missing entries and replacing each question mark with the appropriate integer. Use the following units: K = 210 (kilo), M = 220 (mega), G = 230 (giga), T = 240 (tera), P = 250 (peta), or E = 260 (exa).
Number of virtual address bits | Number of virtual addresses | Largest possible virtual address |
---|---|---|
4 | 16 | 16 − 1 = 15 |
8 | ____ | ____ |
____ | 2? = 64 K | ____ |
____ | ____ | 232 − 1 = ? G - 1 |
____ | 2? = 256 T | ____ |
64 | ____ | ____ |
Virtual memory: warmup II
Consider a (small) machine with a 11-bit virtual addresses, in which 8 bits are used for the VPN. (Assume that the machine is byte-addressable, as with all of the examples we have seen.)
What is the size of the virtual address space, in bytes?
Virtual memory: address translation
This question is also borrowed from CS:APP3e, and lightly modified.
Given a 32-bit virtual address space and a 24-bit physical address, determine the number of bits in the VPN, PPN (your book, OSTEP, calls this PFN), and offset, for the following page sizes P:
P | # of VPN bits | # of PPN bits | # of offset bits |
---|---|---|---|
1 KB | ____ | ____ | ____ |
2 KB | ____ | ____ | ____ |
4 KB | ____ | ____ | ____ |
8 KB | ____ | ____ | ____ |
Virtual memory: address translation II
Consider a (huge) machine that has 60-bit virtual addresses, a page size of 1 terabyte (1 TB, or 240 bytes), and 52-bit physical addresses.
- How many bits is the VPN (virtual page number)?
- How many bits is the PPN (physical page number)?
- How many bits is the offset?
Virtual memory: paging
This question is also borrowed from CS:APP3e.
Determine the number of page table entries (PTEs) that are needed for the following combinations of virtual address size (n) and page size (P).
n | P | Number of PTEs |
---|---|---|
16 | 4K | ____ |
16 | 8K | ____ |
32 | 4K | ____ |
32 | 8K | ____ |
48 | 4K | ____ |
Handing in the homework
Use Gradescope; you can enroll in our course with entry code 4J462V.