OS8 Flashcards

(50 cards)

1
Q

Describe the idea of virtual memory.

A

Virtual addressing allows us to access non-resident pages as if they were normal memory.

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

Define non-resident memory.

A

They are pages on a non-volatile backing store.

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

How is the valid/invalid bit used with virtual memory?

A

Valid/invalid bit is used to mark a page resident/non-resident.

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

State the purposes of using virtual memory.

A

Separate program logical memory from physical memory, allowing logical address space to be much larger than physical address space.

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

Explain the benefits of using virtual memory.

A

Portability: programs work regardless of how much physical memory there is. Convenience: less of the program needs to be in memory at once, making multi-programming more efficient. Efficiency: doesn’t waste physical memory on code or data that isn’t used.

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

Describe the virtual address space.

A

Gives a logical view of how processes are stored in memory. Contiguous address starting at address 0 until end of space.

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

State the hardware requirement for virtual addressing.

A

The memory management unit to map logical to physical addresses.

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

Describe how the stack and heap are stored in virtual address space.

A

The stack starts at maximum logical address and grows down. The heap starts at minimum logical address and grows up.

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

Explain why internal fragmentation in virtual address space does not waste physical memory.

A

Physical memory is not allocated until the heap or stack grows to a new page.

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

Describe how system libraries are shared with virtual addressing.

A

Shared memory between processes by mapping pages into the virtual address space of the processes.

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

Define page fault.

A

A page fault is a trap to the OS sent when an invalid page is referenced.

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

Describe what happens on a page fault.

A

If invalid memory reference, abort. If valid but not resident, find a free page and swap the page in. The page is then marked as valid, and the instruction causing the fault is restarted.

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

State the challenge of handling page faults for instructions that access several memory locations and how to solve it.

A

An instruction may modify memory before causing a page fault, but it must be restarted from the start. Handled by checking all memory locations that will be accessed before running the instruction.

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

What is a double fault?

A

It is when the page fault handler itself triggers a fault.

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

Describe pure demand paging.

A

Start with every page marked as invalid. Bring pages into memory as needed.

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

State the benefit of demand paging.

A

Reduced IO/memory needed and response time.

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

State the hardware requirement for demand paging.

A

Page table with valid/invalid bit. Secondary memory (swap device). Ability to restart instructions.

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

Describe a lazy swapper.

A

It never swaps a page into memory unless the page is needed.

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

State the formula for effective access time (demand paging)

A

$$\text{ETA}=(1-p) \times \text{memory access time} + p \times \text{page fault service time}$$ where $p$ is the page fault rate.

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

Describe copy on write.

A

Parent and child process initially share the same pages in memory. Only copy when a process modifies the shared page.

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

State the benefit of using copy on write.

A

Allows for efficient process creation.

22
Q

State the optimisations for demand paging.

A

Using copy on write. Writing to IO in larger chunks. Keeping a pool of free pages (so you don’t need to free a page during a page fault).

23
Q

How to create a child with copy on write on UNIX?

A

vfork creates a child with a copy on write address space of the parent.

24
Q

How are page faults handled if there are no free frames?

A

Locate a victim page and write it to disk. Restart the faulting process.

25
State the 3 page replacement algorithms.
First in first out, Optimal, Least recently used.
26
State Belady's anomaly and where it can happen.
In a FIFO page replacement algorithm, when memory increases, the number of page faults can increase.
27
Describe the least recently used page replacement algorithm.
It approximates optimal, assumes the past is a good predictor of the future.
28
Describe the optimal page replacement algorithm.
Replace the page that will not be used for the longest time.
29
Describe the two implementations of least recently used page replacement.
Counter: each page table entry holds a counter value representing the last access time. Stack: maintain a doubly linked list of page numbers; when a page is accessed, move it to the top.
30
State the downside of using the counter implementation for least recently used page replacement.
Requires search through the page table on replacement. Requires memory writes (to counter) on access.
31
State the downside with using the stack implementation for least recently used page replacement.
Up to 6 pointers need to be changed.
32
List the algorithms used for approximating least recently used.
Not recently used replacement, Second-chance algorithm.
33
What is the reference bit in a page table entry?
It is initially 0, set to 1 when the page is touched.
34
What does the dirty bit mean in a page table entry?
The page is written to in memory only, and has not propagated to disk.
35
Describe not recently used replacement for approximating least recently used.
Periodically clear reference bits. Victimize pages according to reference and dirty bits.
36
Describe how not recently used can be modified so the reference bit of a page accessed in the past 8 instructions is not set to 0.
Use an 8-bit value, bit shift from the left.
37
Describe the second chance algorithm for approximating least recently used.
Store pages in a FIFO queue. If the reference bit of the head is 0, that's the victim. Otherwise, set the reference bit to 0 and add the page to the queue.
38
Describe and explain the two counting algorithms for page replacement.
Keep a count of the number of references to each page. Least frequently used: replace page with smallest count. Most frequently used: replace highest count page, as a low count indicates the page was recently brought in.
39
Why are counting algorithms not used for page replacement?
They are expensive and don't emulate optimal well.
40
Describe the page buffering algorithm.
Keep a minimum-sized pool of free frames, evict victim when convenient. Keep a list of modified pages - write to disk when it becomes idle. Keep the free frame content intact in case it is needed again.
41
State the problem of frame allocation.
There needs to be an allocation policy to determine how to distribute frames. E.g. whether optimised for fairness or system-wide page-fault rate.
42
Describe the impact of global allocation.
Greater throughput. Process performance depends on what other processes are doing and can vary greatly.
43
Describe local replacement and state its impact.
Each process selects only from its own set of allocated frames. More consistent per-process performance, but underutilizes memory.
44
Explain how thrashing happens.
A page fault requires replacing an existing frame, but it is likely needed to be replaced back soon, causing a high page-fault rate.
45
What is thrashing?
It is the low CPU utilization triggered by an increase in multiprogramming.
46
Define the working set.
The working set is the set of pages required at the same time for a process to make progress.
47
State the formula for demand (working sets)
$$D=\sum_i \text{WS}_i$$ where $\text{WS}_i$ is the working set of the $i$th process.
48
What is demand?
The approximation of locality.
49
State the condition for thrashing.
demand (size of locality) > physical memory
50
What is pre-paging?
Bringing in the working set pages when (re)starting a process.