Lecture 10 - Memory management Flashcards

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

Why is memory management needed?

A

Memory is a resource

Processes need protection

Helps progamming if all memory looks the same

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

What is the memory hierarchy?

A

Smaller memory = faster = more volatile = more expensive

Larger memory = slower = less volatile = cheaper

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

What is the difference between logical and physical addresses?

A

Logical address - virtual address - local to the process, translated by the MMU (memory management unit)

Physical address - what the actual hardware sees

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

In days of job-at-a-time batch programming, how was virtual memory mapped to physical memory?

A

Entire physical memory was for the one job, if it didn’t fit program would manually load the next part into memory

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

Embedded systems use

a) virtual memory
b) physical memory

and hence there may be at most ___________ program(s) running at a time

A

b) physical

one

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

What is swapping?>

A

Saving a programs entire state including memory image onto a disk

Loading another program into memory

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

What two things does multiprogramming need from memory? Why?

A

Relocation - mem wont always be in same place so cant use absolute memory locations

Protection - multiple programs must not be able to access other programs memory

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

What is contiguous memory allocation?

A

Memory is partitioned into many spaces

When a process wants to run it requests a certain amount of memory

if its available OS allocates it to the process

otherwise process has to wait

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

What are base and limit registers?

A

Base register - defines the lowest address (start address) of the memory space of a program

Limit register - defines the size of the memory allocated a process

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

How does the memory management unit map logical addresses?

A

Takes offset and compares to limit register. If > limit register, raise protection fault, else add to base register - resulting address is physical memory address

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

What is segmentation?

A

A program is a collection of segments

Each segment could be allocated somewhere different in physical memory

Need a segment table with base/limit per segment to map logical to physical addresses

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

What are the pros and cons of segmentation?

A

Pros: segments are logical to us and facilitate sharing and reuse

protection can be set per segment

Cons: variable sized partitions need tricky dynamic allocation

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

What is paging and what problems does it solve?

A

Process sees memory as one contiguous space

in reality pages are scattered across actual hardware

each page the same size, efficiently uses memory and can have protection per page

Solves external fragmentation problem by using fixed size units in physical and virtual memory

Solves internal fragmentation by making the units small

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

What is a page table?

A

Table that maps pages in a process’ virtual memory to page frames in physical memory

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

How is address translation done with paging?

A

Virtual address has two parts: page number and offset

Page number corresponds to entry in page table

offset refers to offset from the base address of the page

16
Q

What are page tables managed by?

A

The os

17
Q

Why will every data/instruction access require two memory accesses?

A

Have to look up page table and then the actual data once the right address is obtained

18
Q

What is a translation lookaside buffer?

A

Very fast cache that stores a list of recently translated addresses - if address to be looked up is found it is very quickly returned, otherwise the phyiscal memory must be accessed to find the right page

hardware associative array searched in parallel

19
Q

Why can logical memory be much larger than physical address space?

A

Only part of the program needs to be in the memory to run

20
Q

When a page in the page table has been moved to the disk, it will be marked as _________

A

invalid

21
Q

What is a page fault?

A

When a process tries to access a page marked invalid, either because

a) the page has been moved to the disk and needs to be retrieved
b) the page never existed

22
Q

What happens when a page fault occurs?

A

Process suspended, enter kernel mode

os brings requested page into memory:

  • find free page frame in memory
  • find page on disk
  • fetch page into frame
  • update page table with page frame
  • mark page as valid in page table

restarts the interrupted instruction

process continues none the wiser

23
Q

What is demand paging?

What are the benefits?

A

Bring a page into memory only when it is needed

Less I/O needed

Less memory needed

Faster response

More users

24
Q

What do fetch strategies describe?

A

When should a page or segment be brought into primary memory from secondary storage (disk)?

  • Demand fetch
  • Anticipatory fetch
25
Q

What do placement strategies describe?

A

When a page or segment is brought into memory where shall it be put?

Trivial with paging

With segmentation, difficult

26
Q

What do replacement strategies describe?

A

Which page/segment should be replaced if there is not enough room for a required page/segment?

27
Q

What is optimal page replacement algorithm?

A

Try to replace the page that will be used furthest in the future

Not really achievable in real systems since we cant predict which pages will be needed

28
Q

What is Not-Recently-Used algorithm?

A

Each page has reference bit and dirty bit

Paged classified into 4 classes: not ref or dirty, not ref dirty, ref not dirty, ref and dirty

Clear reference bit for all pages periodically

Algorithm: remove a page at random from the lowest non-empty class, i.e. preferably not referenced or dirty

Decent performance

29
Q

What is the FIFO algorithm?

A

Maintain linked list of all pages

Page at front of list replaced

Very easy to implement

Not always performant - page in memory the longest may be often used, this forces it out regardless

30
Q

What is second chance page replacement?

A

Modify FIFO to avoid throwing out heavily used pages

Give each page reference bit

If reference bit is 0 throw it out, if 1 reset it to 0, move to the end of the list, continue to search for a free page

31
Q

What is Least Recently Used algorithm?

A

Assume pages recently used will be used again soon

Throw out page that has been unused for the longest time

32
Q

What is thrashing?

A

If the page-fault rate on a system is too high because there are not enough pages, a process will spend more time paging than it will executing

Low cpu utilisation

Os thinks it needs to increase the degree of multiprogramming so more cpu is utilised

Even more paging happens

Throughput plummets

33
Q

How can thrashing be controled?

A

Establish acceptable page fault rate

If too low, too many frames - give more processes

If too high, too few frames, hold back some processes

34
Q

What is the resident set of a process?

A

Number of pages a process is allocated

35
Q

What is the working set of a process?

A

The set of pages referenced in the last X memory references

Indicates size of memory locality

36
Q

What is copy-on-write?

A

Allows parent and child processes to share pages that are the same

If either one modifies a shared page, only then is it copied elsewhere

37
Q

What is a memory-mapped file?

A

Where a disk block is mapped to memory page

So memory accesses on that page are actually I/O processes

Several processes using the file can use the same shared memory block