P3L2 Memory Management - Memory Allocation Flashcards

1
Q

Kernel level allocators are responsible for allocating __________________ and for keeping track of ______________ that is available in the system.

User level allocators are used for _____________________________.

A

Kernel level allocators are responsible for allocating pages for the kernel and for keeping track of the free memory that is available in the system.

User level allocators are used for dynamic process state - the heap.

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

Name two challenges for the memory allocation system

A

An allocator must allocate memory in such a way that it can quickly coalesce free page frames when that memory is no longer in use in order to limit external fragmentation.

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

The linux kernel relies on two main allocators: the _______ allocator, and the ______ allocator.

A

The linux kernel relies on two main allocators: the buddy allocator, and the slab allocator.

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

Describe the buddy allocator.

  • What’s its advantage?
  • Disadvantage?
A

Subdivides memory into two - finds smallest contiguous chunk that will accomodate the requested memory.

  • Advantage: Quickly coalesces free memory
  • Disadvantage: Because of the power of 2 structure, causes internal fragementation if object is of a non-power-of-two size.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is demand paging?

A

the backing physical page frame can be repeatedly saved and stored to and from some secondary storage, like disk.

present bit in the paging table entry set to 0. When there is a reference to that page, then the MMU will raise an exception - a page fault - and that will cause a trap into the kernel.

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

When would you disable swapping?

A

This is useful when the CPU is interacting with devices that support direct memory access (DMA), and therefore don’t pass through the MMU.

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

When should pages be swapped out of main memory and on to disk? Name 2 conditions

A

Pages should be swapped when the memory usage in the system exceeds some threshold and the CPU usage is low enough so that this daemon doesn’t cause too much interruption of applications.

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

Which pages should be swapped out?

Name 3 policies/algorithms

A
  1. Least-Recently Used (LRU) policy. This policy uses the access bit that is available on modern hardware to keep track of whether or not the page has been referenced.
  2. Dirty bit - pages that don’t need to be written (not dirty) can be swapped
  3. Second chance - variation of the LRU policy, which gives a second chance. It performs two scans before determining which pages are the ones that should be swapped out.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

LRU quiz

Suppose you have an array with 11 page size entries which are accessed one by one in a loop. And then they are manipulated again, one by one in a loop (so two loops accessing all 11 entries).

Suppose the system only has 10 pages.

What is the percentage of pages that will be demand swapped?

A

The answer is 100%,

because the 2nd loop guarantees that all the pages will be swapped out 9 (and the next swapped) in.

So the demand paging covers all the pages.

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

When we need to create a new process, we need to re-create the entire parent process by copying over its entire address space.

Name the hardware supported mechanism that saves the copy cost

A

Copy-on-Write

Virtual address in new process’s address space just points to the same physical memory as the parent is pointing.

OS write protects the physical memory

If new process tries to write —> FAULT!

And only then the OS allocates new physical memory.

So that’s why it’s called COPY ON WRITE!!

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

Checkpointing is a ____________________________ technique. The idea behind checkpointing is to __________________________

A

Checkpointing is a failure and recovery management technique. The idea behind checkpointing is to periodically save process state.

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

What are the advantages and disadvantages of frequent checkpointing?

A

Advantages: more states will be checkpointed, faster recovery from a fault

Disadvantage: Overhead of saving state ..

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