Virtual Memory Flashcards

1
Q
  1. [2pts] We’ve discussed the physical address space of the system and how it relates to the virtual address space of a process. The physical address space of the system is determined by what feature of the system?
A
  • The amount of memory available

- Memory management system?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. One of the big problems we encountered as we managed physical memory was that of fragmentation.
    (a) [4pts] Name and define the two types of fragmentation.
A

Internal Fragmentation: Wasted space within a unit of allocation
External Fragmentation: Wasted space between units of allocation

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

(b) [3pts] Why do we consider fragmentation to be a problem?

A

It’s wasted space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. One of the memory management techniques we studied was relocation.
    (a) [2pts] Relocation suffers from what type of fragmentation?
A

External fragmentation

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

(b) [2pts] How do we eliminate that fragmentation with static relocation?

A

We don’t

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

(c) [2pts] How do we eliminate that fragmentation with dynamic relocation?

A

Defragmentation (Compaction)

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

Paging divides a process’s virtual address space into equally-sized pieces.
1. [2pts] How does the size of the virtual address space relate to the size of the physical address space?

A

The virtual address space is usually much bigger than the physical

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
2. One day, at home, for fun, you decide to write a program in C. Unfortunately, your program is
very buggy (Did you just add a ’*’ ?), and so you use gdb to find and eliminate the bugs.

(a) [4pts] You print a stack backtrace, and gdb displays the stack along with the address of
each function call. Are these addresses virtual or physical?

A

Virtual

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

(b) [10pts] How would the system use that address to access the data it represents? Please
describe the steps of the process in a numbered list, and please be sure to include the TLB! Each step should be no more than twenty words.

A

(1) A concurrent request is sent to the TLB and the page table to find the translation of page number to frame number.
(2) If the translation is found in the TLB, then the request to the page table is stopped, and the frame number is returned.
(3) If the translation is not found, the translation is found in the page table and the translation is added to the TLB.
(4) The offset from the virtual address is added to the frame number to get the physical address.

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

As we studied virtual memory, we discovered that there are many places to improve efficiency, and therefore there are many policy decisions to be made. We discovered that many policies exist, largely because there are advantages and disadvantages to each.

  1. [3pts] Most systems use demand paging. How does demand paging increase efficiency?
A

It doesn’t load in pages until you need them, preventing unnecessary work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. [3pts] Some systems use pre-paging. How might pre-paging increase efficiency?
A

Pre-paging might increase efficiency if you load in all the right pages because it will result in less page faults

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. [3pts] We saw that there were many possible page replacement policies. Why is the page
    replacement policy important? How does it affect efficiency in the system?
A

It is important because it will run on every page fault, and will affect to the overall efficiency of the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. [3pts] Some systems implement the working set technique in addition to using a page replacement algorithm. How might that combination increase efficiency?
A

Working set will decrease the amount of times the page fault handler needs to run by preemptively evicting pages and not letting memory fill up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. [3pts] At this time, page sizes are increasing. How might a larger page size increase efficiency?
A

Larger page size can increase time efficiency because the system will page-fault less and increase space efficiency because the page table is smaller.

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

Relocation
One of the memory management techniques we studied is known as relocation.
1. [4pts] What is the main idea behind relocation?

A

Increase degree of multi-programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. [2pts] In relocation, what type of address is generated by the compiler?
A

Physical address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  1. [2pts] In static relocation, what type of address is generated by the CPU?
A

Virtual address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
  1. [2pts] In dynamic relocation, what type of address is generated by the CPU?
A

Virtual address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
  1. For each of the space management technique below, list whether the technique suffered from
    internal fragmentation, external fragmentation, neither, or both. If you feel your answer needs
    justification, justify it.
    (a) [2pts] Relocation
A

External

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

(b) [2pts] Paging

A

Internal

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

(c) [2pts] Contiguous files

A

External

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

(d) [2pts] Linked files

A

Internal

23
Q

(e) [2pts] Multilevel Indexed Files

A

Internal

24
Q

Memory Management
On just another day at AwesomeCompany, your fellow employee approaches you and comments that the paging system in use by AwesomeCompany’s OS seems unnecessarily complex, and that it would be simpler and more efficient to just place the processes contiguously in physical memory.
1. [4pts] Name two advantages to the suggested policy.

A

Less complex.

No overhead of page table lookup.

25
Q
  1. [4pts] Name two disadvantages to the suggested policy.
A

External fragmentation.

Growing a process is hard.

26
Q
  1. [2pts] Has the suggested policy been used before? If so, what was its name?
A

Yeah, static relocation

27
Q
  1. [4pts] This suggested policy might work well in systems with certain characteristics. Name two.
A

Uniprogramming

A dire need to reduce overhead

28
Q

Overview
1. [3pts] One of our topics this semester is virtual memory. What are the goals of virtual memory in a computer system? Name two.

A

(a) Give the illusion of infinite memory

(b) Provide security between processes

29
Q
  1. [3pts] What causes a memory exception? What is the end result?
A

(a) Page fault
(b) Dereferencing null
(c) accessing an address that does not belong to the process’s address space

Page fault is a handled exception, but in the other two cases, the process is killed.

30
Q
  1. [3pts] What causes a page fault? What is the end result?
A

Reference to unmapped page

(1) unmapped is read in
(2) page table updated
(3) faulting process unblocked

31
Q

Early Memory Management
1. When we began to consider how the operating system manages memory, we first considered a uniprogramming environment.
(a) [2pts] Considering our overall goals for the memory subsystem, name two limitations of
Uniprogramming.

A

(a) Only one user can work at a time.

(b) There is no concurrency.

32
Q

(b) [2pts] In uniprogramming, how does the system assign physical addresses to a process and
then adjust the process’s addresses to the assigned ones?

A

Process is always loaded starting at address 0.

33
Q
  1. We solved at least one limitation of uniprogramming through relocation.
    (a) [2pts] What limitation of uniprogramming did relocation eliminate?
A

Allows for multiple processes to run concurrently.

34
Q

(b) [2pts] How does the system choose which physical addresses to allocate to a process?

A

*-fit algorithms

35
Q

(c) [2pts] In static relocation, how does the system adjust the process’s logical addresses to
the assigned physical ones?

A

During load

36
Q

(d) [2pts] In dynamic relocation, how does the system adjust the process’s logical addresses
to the assigned physical ones?

A

Bound and base registers

37
Q

(e) Both relocation models had some limitations.
i. [2pts] In particular, in relocation each process must fit entirely in memory. What was
an early solution to that problem (before paging)?

A

Overlays

38
Q

ii. [3pts] Name three other limitations of relocation algorithms.

A

(a) External fragmentation
(b) Cannot grow processes easily
(c) Can’t have processes larger than physical memory

39
Q

Managing Paging
As with so many things we studied, the paging environment exists to manage hardware and yet
requires a lot of management itself.
1. [4pts] One of the main ideas behind paging is the existence of pages and frames. What are they and how do they relate?

A

Every page is the unit of virtual memory that maps to a frame, which is the unit of physical memory. They have the same size.

40
Q

(b) [4pts] Since the executing process is clearly trying to access something on that page, what
happens next? Describe how the system does or does not find that page.

A

The page is not in resident memory. This means that the page is in swap or has not been loaded from the filesystem yet. The page gets paged into the memory.

41
Q

(c) [2pts] Assume physical memory is full and that this system is using the clock page replacement algorithm. What information will it consider when choosing a page to evict?

A

Resident bit and reference bit

42
Q

(d) [4pts] Once you choose a page to evict, what steps do you need to take to complete the
eviction? Be certain to remember to update metadata structures.

A

(1) Write the chosen page to swap if it is dirty, and clear the dirty bit
(2) Update the page table entry to reflect where the page now resides (swap), and set resident bit to false.
(3) Mark the associated frame as free.

43
Q

Virtual Memory Concepts

1. [2pts] What is a page?

A

Unit of allocation in virtual memory

44
Q
  1. [2pts] What is a frame?
A

Unit of allocation in physical memory

45
Q
  1. [2pts] How does a page relate to a frame?
A

Same size

46
Q
  1. [2pts] What is a TLB and what does it contain?
A

Translation Lookaside Buffer - it contains recent accessed page table, frame translations for the current process.

47
Q
  1. [2pts] What is swap?
A

A partition on disk.

48
Q
  1. [2pts] What is thrashing and why does it matter?
A

When pages are evicted right before they are needed. It dramatically decreases CPU performance.

49
Q
  1. Paging gave us several advantages over prior memory management techniques.
    (a) [2pts] How does paging enable sharing?
A

Different page table entries can point to the same frame.

50
Q

(b) [2pts] How does paging enable multiprogramming?

A

Multiple processes can fit in physical memory at the same time. It provides support for processes larger than the physical memory itself.

51
Q

Memory Management
1. [4pts] We began this part of the course by discussing memory management in the operating
system. Name two functionalities that the OS provides for the user as it manages memory.
(Hint: Think of the hats!)

A

(a) Illusion of infinite memory (Ilusionist)

b) Protection around memory accesses (Referee

52
Q
  1. In the pursuit of multiprogramming, the idea of relocation was introduced.
    (a) [4pts] We studied two forms of relocation. What are they and what is the essential difference between them?
A

Static and dynamic relocation

when addresses are adjusted (at compile time, dynamically)

53
Q

(b) [3pts] Both forms of relocation suffer from a very big, wasteful drawback. What is it?

A

External fragmentation