Lecture 16: Memory Management Flashcards

1
Q

Memory Management Unit Responsibilities

A

-Another Resource Manager Component of the OS

  1. Memory Allocation:
    responsible for allocating memory to processes
  2. Address Mapping:
    Necessary: 1) to run same code in different physical memory in different processes 2) to support process address space abstraction MMU responsible for mapping logical addresses generated by CPU instructions to physical addresses seen by memory controller
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logical Addresses

A
  • An abstraction of memory
  • memory referenced in assembly language instructions (e.g., BR X, LOAD R2,Y)
  • starts at 0, contiguous
  • reality: must be mapped to physical addresses (address mapping)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Logical Addresses Generated at:

A
  1. Compile-time
    • relative addressing resolved here(e.g.:X,Y)
  2. Link, load-time
    • addresses dependent on external modules resolved here
  3. Execution-time
    • addresses generated by dynamic loading/linking resolved here
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Logical Address Space

A

defined by base and limit registers

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

Base and Limit Registers: CPU

A

every physical memory access request must be between base and limit for that user

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

Generating Physical Addresses

A

• addresses used in MAR (memory address register)
• generated at runtime (execution time) by
memory management unit (MMU)
• above protocol enables dynamic program relocation (without having to modify program code)

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

Memory Allocation Goal 1: High Utilization

A

• ensure as much memory used as possible (minimize waste) (e.g.: want to use as much of street for street parking as
possible)

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

Memory Allocation Goal 2: High Concurrency

A

• support as many processes as possible

e.g.: cars exit when don’t require parking any more, so others can use

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

Memory Allocation Goal 3: Fast

A

-fast

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

Memory allocation: contiguous

A

-no gaps

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

Memory allocation: non-contiguous

A

-with gaps

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

Contiguous Pros and Cons

A

Pros:

  • Easy implementation
  • Easy to conceptualize

Cons:
-Poor memory utilization

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

Contiguous Types

A
  1. Fixed Partition allocation (parking lot)

2. Variable Partition allocation (side street parking)

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

Fixed Partition allocation (parking lot)

A
  1. Idea:
    • divide memory a priori into fixed partitions (can vary in size) e.g.: parking lot: regular spaces, compact only, etc.
  2. Allocation Policy:
    • process P arrives needing k units of space:
    choose partition (Ri) that is smallest but 3 k (best-fit)
  3. Utilization Issue:
    • internal fragmentation: parts of allocated partition unused
  4. Implementation:
    • requires limit and relocation registers

5.

In Practice: used in early batch systems:
1. knew memory needs of processes in advance
2. memory needs didn’t change much over process lifetime

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

Variable Partition allocation (side street parking)

A
-Idea:
• allocate memory chunks as needed (analogous to side street parking)
-best fit
-worst fit 
-first-fit
-next-fit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Variable Partition allocation policies

A

Allocation policies:
process P arrives needing k units of memory

a. Best-fit: choose hole that is smallest but ≥ k
b. Worst-fit: choose largest hole
c. First-fit; choose first hole with size ≥ k
d. Next-fit: choose next hole with size ≥ k

17
Q

Fragmentation types

A
  1. External:
    total memory exists to satisfy request, but not contiguous.
    External fragragmentation can be periodically eliminated via compaction
  2. Internal:
    allocated memory may be > requested memory. Extra memory not used
18
Q

Non-contiguous allocation

A

Idea:

Logical address space is partitioned, each partition mapping to a contiguous chunk of memory

19
Q

Non-contiguous allocation: pros and cons (compared to contiguous)

A

Pros:
• better memory utilization
by dividing address space into smaller “chunks,” more
memory fragments can be used

Cons:
• more complex implementation (not just relocation & limit registers)

20
Q

Non-contiguous schemes (3)

A
1. paging
all chunks the same size
(i.e.: chunks are physically determined)
2. segmentation
chunks are variably sized (logically determined)
3. paged segmentation
hybrid of (1) and (2)
21
Q

Page Table Implementation

A

Every Process’ Page Table:

  • kept in main memory
  • location kept in process (special status) registers:

Page-table base register: (PTBR)
• location of page table for process

Page-table limit register: (PTLR)
• size of process page table

22
Q

Caching

A

Use of high-speed memory to hold frequently accessed data

23
Q

Associative Memory (TLB’s)

A
  1. Cache is faster than memory

2. Associative Memory permits parallel search

24
Q

Issues with paging

A

Issue #1: Two memory accesses / logical address reference

Solution: TLB
Issue #2: Very large page tables

Solution: Page the page tables!! (Multilevel Paging)

25
Q

Segmentation

A

Idea:
Segmentation
• Similar to paging but, partitions of logical address space / physical memory are variable, not fixed
-partitions based on conceptual divisions rather thαn page size

26
Q

Segmentation architecture

A

-Segment tables (one per process)
-Every process PCB holds …
1. Segment Table Base Register (STBR)
• location of segment table in memory

  1. Segment Table Length Register (STLR)
    • number of segments used by program
27
Q

Advantages of segmentation

A
  1. Easier to implement protection
    e. g.: Text segment should be read-only. Can add flags to segment table:
  2. Read-only: Prevents writes to text segment
  3. No-execute: Prevents attempts to execute entries in data segment

Paging:
Page can contain both code & data. (Protection is trickier)

  1. Easier to implement sharing
    •e.g.: same text segment can be used by multiple processes concurrently
28
Q

Advantages of paging

A
  1. Memory utilization
    • paging suffers from internal fragmentation but at most, 1 page / process
    • segmentation suffers from external fragmentation which over time can make much of memory unusable
  2. Multilevel paging allows page tables to be non-contiguous
    • can do the same for segment tables… (paged segmentation)
    • idea: segmentation-basedallocation,buteverysegmentispaged
29
Q

Locality

A

successive memory accesses tend to be of addresses close to each other