OS Support Flashcards

1
Q

What is the main purpose of virtual memory?

A

To give each application the illusion that it has its own address space, isolating processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is responsible for translating virtual to physical addresses?

A

Processor and OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the advantages and disadvantages of using megapages instead of pages?

A

+ Optimise page table
+ Exploit locality
- Less flexibility to move data around

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When paging, we can migrate rarely used pages to disk. What are the advantages and disadvantages of this?

A

+ Gives the illusion of a bigger memory
+ Useful to deal with programs with a larger working set
- Slow if paging to magnetic disk
- Risks wearing out flash disk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Draw a diagram demonstrating the concept of address translation

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the trade-off when increasing cache size?

A

+ Decrease capacity misses
- May increase access time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the trade-off when increasing associativity?

A

+ Decrease conflict misses
- May increase access time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the trade-off when increasing cache-line size?

A

+ Decrease compulsory misses
- Increases miss penalty
- Very large cache line size may increase miss rate due to pollution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a level-1 cache?

A

Attached to CPU, small, low latency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a level-2 cache?

A

Services misses from leve1/primary cache, larger, slower but still faster than main memory, off-chip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What services level-2 cache misses?

A

Main memory, of level-3 cache if the system has one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which cache is the last-level cache?

A

Closest to DRAM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Look over multilevel cache example calculation slide

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a TLB?

A

Translation Look-aside Buffer
Cache of PTEs (ie. cache of page table)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why do we use a TLB?

A

Address translation without it would always require 2 memory references per instruction: one to access the PTE to get the physical address the virtual address maps to, then the actual memory access using the physical address
The TLB is a fast cache of PTEs within the CPU so frequently accessed pages only require 1 memory access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What property enables TLBs to help performance?

A

Access to page tables has good locality ie. if you access one bit in a page you are likely to access another bit in the same page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

TLB lookup is usually performed ? ? ? L1 cache access

A

in parallel to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Describe the structure of a page table

A

If a page is present in memory:
Contains status bits: valid, dirty, reference. Table of physical addresses, indexed by virtual address
If page is not present in memory:
PTE refers to a location in swap space on disk
Software Page Fault Handler invoked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Describe the structure of the TLB

A

Contains status bits: valid, dirty, reference. Table of tag and physical addresses, indexed by virtual addresses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Draw a diagram demonstrating how the TLB is used in virtual address translation

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How is a TLB miss handled if the page is in memory?

A

Load the PTE from memory and retry
Could be handled in hardware or in software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How is a TLB miss handled if the page is not in memory (page fault)?

A

OS handles fetching page and updating page table, then restarts faulting instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a hardware page table walker?

A

Piece of software that is invoked if there is a TLB miss
Walks the page table to search for the PTE
If PTE is found it gets put into TLB, if PTE not found there is an exception to OS.
Memory operations are then typically replayed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a page table register?

A

Register in CPU that points to page table in physical memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the Page Fault Handler do?
Uses faulting virtual address to find PTE: 1. Locate page on disk 2. Choose page to replace If dirty, write to disk first 3. Read page into memory and update page table 4. Make process runnable again Restart from faulting instruction
26
What can be done to minimise page fault rate?
1. Fully associative placement (any page on disk can be mapped to any page in memory) 2. Smart replacement algorithms
27
What handles the fetching of a page from disk?
OS
28
Which replacement policy is used when mapping pages to disk?
LRU
29
Disk accesses are slow, so careful management is critical when mapping pages to disk. Give an example
If dirty bit is not set then don't write the page back to disk
30
Page table allows ? ? mapping of pages to disk
fully associative
31
Draw the structure of a virtual address
.
32
Draw the structure of a page table entry for a page
.
33
Draw the structure of a physical address for a page
.
34
What is the standard page size?
4KiB
35
Describe a multilevel page table
Page table represented as a tree. This compacts the structure and means each section of the page table fits into a page
36
What is the SATP register?
Supervisor address protection and translation. Holds the base of the tree in the physical page number (PPN) field
37
What is the disadvantage of using a one-level page table?
Would be 2^20x4 = 4MiB, much of it unused
38
Give the equation for the first PTE lookup address
SATP.PPN x PAGESIZE + VPN[1] x PTESIZE
39
What is the standard megapage size?
4MiB
40
Is the virtual address structure the same for megapages as pages?
Yes
41
Draw the structure of a page table entry for a megapage
.
42
Draw the structure of a physical address for a megapage
.
43
With both pages and megapages, the offset in the virtual address is used as the offset in the ? ?
physical address
44
Draw a diagram of a megapage lookup
.
45
Draw a diagram of a page lookup
.
46
Give the equation for the lookup address for a secondary page lookup in memory
lookup address = {PPN[1], PPN[0]} x PAGESIZE + VPN[0] x PTESIZE
47
How does virtual addressing do memory protection?
- Different applications are allocated their own virtual address space - Different applications can share parts of their virtual address space, but OS protects against errant access - There is hardware support for OS protection
48
How does the system handle different applications having their own virtual address space
1. Pointer to page table changed during context switch 2. TLB entries often include Address Space IDentifier (ASID) so TLB can hold translations for different virtual address spaces
49
Give 3 examples of hardware support for OS protection
1. Kernel mode 2. Privileged instructions 3. Page tables are only accessible in supervisor mode
50
What is an operating mode?
A mode that: 1. controls how much of the physical address space is visible 2. limits access to privileged instructions 3. limits access to control-status registers (CSRs)
51
List the 3 operating modes on RISC-V from most to least restricted access
1. User (U-mode: applications) 2. Supervisor (S-mode: OS-layer) 3. Machine (M-mode: supervisor execution environment)
52
Draw an example software implementation stack
.
53
What is an ECALL instruction? Give an example of when it would be used
Used to call into a more privileged mode eg. used by ABI to transition from U-mode to S-mode
54
What is an SRET instruction? Give an example of when it would be used
Trap return from S-mode eg. used by OS to transition from S-mode back to U-mode Set PC to EPC value and change modes
55
What is the EPC register?
Exception PC register, saves the PC of ECALL, hidden ot U-mode
56
What are the ECALL and SRET instructions used for?
To enter and exit a software interrupt, they are environment calls
57
Interrupts, exceptions and software interrupts all use very similar hardware - what does this do? What do interrupts do in addition?
Jump to some privileged code and change privilege mode Interrupts also cause a trap, but based on external factors not instruction execution
58
What are the 3 types of interrupt?
1. Timer interrupts - used for scheduling 2. DMA interrupts - used to indicate the end of a transfer 3. I/O device interrupts - trigger execution of a device driver
59
What are exceptions caused by? Give 3 examples of exceptions
Instruction stream 1. Illegal instruction 2. Division by 0 3. Page fault
60
What is a software exception caused by?
An ECALL instruction
61
List 5 types of hardware support for operating systems
1. Execution modes 2. Exceptions, interrupts and software exceptions 3. Privileged instructions 4. Privileged registers 5. Virtual memory