Swapping Flashcards

1
Q

What is swapping?

A

Swap inactive pages out of memory temporarily on another level of storage (most of the time HDD) to gain memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • What is the swap space?

- Where is the swap space stored?

A
  • The level of storage defined for swapping

- Mostly a swap partition (linux) or swap file (windows)

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

Paging:

  • What is the present bit?
  • What happens if it is not set?
A
  • The present bit belong to the PTE. If set the page is in physical memory.
  • HW makes a trap with page fault
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A page fault gets started by the HW if pages are not in physical memory. This gives the control to the OS.

  • Why does the HW not handle this? (3 reasons)
  • How is the control given?
A
  1. HW would have to know how swapping and swap space works
  2. Swapping to HDD is slow, we gain no benefit of using the HW
  3. HW would need to know disk driver and different HW types (SATA, SCSI)
    - HW trap into OS, where the page fault handler gets into action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe how the OS handles the page fault from start until memory access.

  • How does the process work during handling the page fault?
  • What if there is no free space in physical memory?
A
  1. Use PFN from PTE, which holds the disk address where the page is stored (if present bit is not set)
  2. I/O to load page from swap space
  3. Update PFN in PTE (using the physical memory address)
    - The process is in state “blocked”. OS can schedule other processes
    - Other pages have to be swapped out first
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does the OS swap out pages? page-by-page?

A

No, there is a minimum of free pages in physical memory. If it is below that, the OS swaps out as much pages until it is above this minimum. This is for optimization of workload.

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

What is a “cold-start miss”? (Often also called compulsory miss)

A

When pages have to be loaded in the memory, those are TLB misses, but are compulsory.

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

What is the problem with simple swapping policies like FIFO or random?

A

They don’t make use of the past and maybe evict important pages. Locality of reference!

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

How does the Linux replacement policy work?

A

2 lists are used: active and inactive

  1. On first page access the page goes into inactive list
  2. If it is used again it gets into active list
  3. If a page needs to be swapped those from inactive are swapped
  4. Periodically pages from active get into inactive
  5. Approximation to LRU similar to clock policy is made.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly