Memory Management Flashcards

1
Q

What is paged-based memory management?

A

Virtual memory is divided into pages, physical memory is divided into page frames (same size as pages). Pages tables map pages to frames

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

What is segment based memory management?

A

Virtual memory mapped into variable-length segments. Uses segment registers supported by hardware

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

What are the ways that hardware supports memory management?

A

MMU, registers, cache, memory translation

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

What is the MMU?

A

Memory management unit - included in the CPU and does address translation VA->PA. Reports faults if access is not allowed

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

What is the TLB?

A

Translate Lookahead Buffer. Part of the hardware cache that stores VA->PA mappings

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

What is allocation on first touch (aka demand paging)?

A

PA is only allocated when the program first tries to access it.

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

What is the purpose of a validity bit in a page table?

A

1 = page is valid and in memory, 0 otherwise ==> MMU will raise a fault, OS must decide what to do (swap, allocate PA, or page fault)

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

How large is a page table?

A

Total virtual addresses = 2^32
number of virtual pages = 2^32 / page size
need total / pages * entry size ==> does not scale

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

Explain a multi-level page table

A

Consists of an outer-page table and inner page table. First part of address is an index into outer table, which points into inner page table (which is a real page table). Then that points to the page frame. Size of inner page table == page frame. Size of outer page table == 2^remaining bytes

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

What are the benefits of a multi-level page table?

A

You do not have to allocate a page table for the entire page space. Any gaps in memory equal to page size * 2, can result in NULL in the outer page table

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

What are the pros/cons of adding more levels to page tables?

A

More levels == smaller page size == less wasted memory, but also means slower lookup times

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

What is an inverted page table?

A

IDK

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

What is external fragmentation?

A

When memory page allocation gets fragmented so that there is enough free memory to fulfill an alloc request, but it is not contiguous (and therefore the memory cannot be allocated)

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

What is the memory allocator?

A

Determines the VA->PA mappings

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

What is the buddy allocator?

A

Start with memory area of 2^x, when a new request comes in, divide area by 2 until it is just big enough

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

What is the slab allocator?

A

Creates caches for common objects / sizes, sits on top of physical memory. Avoids fragmentation

17
Q

What is demand paging?

A

When a page has been swapped out of main memory to disk and needs to be put back into memory because of an access –> hardware will trap to OS, which will swap the page before returning control back to the process

18
Q

What is a pinned page?

A

A page that cannot be swapped

19
Q

What is page replacement?

A

When you swap pages to disk. Want to swap pages that won’t be used soon - LRU or pages that haven’t been modified since reading them from disk (dirty bit in MMU)

20
Q

When are pages swapped out?

A

When amount of memory in main memory hits a certain threshold and when CPU usage is low

21
Q

What is Copy-on-Write?

A

When fork a process, a lot of the memory is the same. Set P2’s pages to read only and just point them to P1’s PA. When P2 wants to modify one, then you copy the page over (via a trap)