Swapping Flashcards

1
Q

Why do we need to swap memory?

A

Address spaces are virtual, so may be larger than actual memory. Thus, we will have to store some of the address space in the hard disk, and swap it into main memory when it is needed.

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

What is a swap space? Why is the present bit in the page table entry important in this regard?

A

A swap space is an area on the disk where we can move things back and forth between memory and the disk easily.
The present bit will indicate whether a page is loaded into main memory or if it is still on the disk.

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

What will happen if we try to access a page that has the present bit set to 0?

A

This will cause a page fault. The OS handles this by swapping in the page from the hard disk (the location where it is stored on disk is given in the page table entry).
While this is all happening, the process will be blocked.

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

Why do we need page replacement policies? What is the aim?

A

If memory is full and we want to swap in a page from the disk, we must know which page to swap out to make space.
The aim is to reduce the number of times which we are required to read from the disk.

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

What is a low watermark and high watermark?

A

When deciding when to start evicting pages from memory, we check how many there are. If there are lower than LW spaces left, we start evicting, but if there are more than HW left we stop evicting.

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

What is the optimal page replacement policy?

A

When you know exactly which page will be access furthest in the future. You choose to evict that one. This is not really practical, but is good for benchmarking other policies.

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

What is FIFO page replacement policy?

A

First in First Out. Simple to implement, but does not take into account importance of certain pages.

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

What is random page replacement policy?

A

Pick a random page to evict. Simple, but depends on how lucky you are.

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

What is LRU page replacement policy?

A

Least Recently Used. The idea is that if we used a page a while ago, we may not need it again so soon.
This is similar to Least Frequently Used.

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

How can we approximate LRU page replacement policy?

A

If we use a reference bit in page table entries, to tell us whether a page has been used recently. If the bit is set to 1, then this entry has been used recently. We must have a way of periodically clearing the reference bit.

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

Why might it be preferable to evict “clean” pages, which do not have the dirty bit set?

A

The dirty bit means that a page has been modified. If we evict one of these pages from the TLB, then we must also write it back into memory, which is costly. It is cheaper to evict a page which does not need to be written.

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