Docsity

Memory Management in Operating Systems: Principle, Memory Hierarchy, and Paging - Prof. B., Study notes of Operating Systems

Partial preview of the text

Download Memory Management in Operating Systems: Principle, Memory Hierarchy, and Paging - Prof. B. and more Study notes Operating Systems in PDF only on Docsity!

CMSC 321:CMSC 321:

Operating Systems

Lecture 11

Memory ManagementMemory Management

Reading: Silberschatz Chs. 8

and 9and 9

Memory Management?Memory Management?

• Principle Operation:

Principle Operation:bring programs into RAM for execution

• Memory Hierarchy:

speed/cost vs

size; volatility

– speed/cost vs. size; volatilityOS

di

d

• OS must coordinate and manage

  • transparent to user

Fixed Partitioning

P

titi

RAM i

t^

fi

d

i^

i

  • Partition RAM into fixed-size regions• Problems?
    • if program too big for partition– internal fragmentation
      • Non-equal partitions help little

Dynamic Partitioning

-^

Partitions: vary # and length

-^

When program brought in allocate amt needed, no more

-^

Problems?

Dynamic Partitioning Algs

  • How to place programs into memory?
    • Best-fit:

find partition that results in least waste

  • First-fit:

scan from beginning until program fits

  • Next-fit:

scan starting from last placement

  • Which is best?
    • first-fit: simplest, best, fastest– best-fit: usually worst performer (why?)– next-fit: slightly worse than first-fit

g

y

What is the Problem?

  • Requires contiguous blocks in memory
    • What if there is enough memory for a new

process, but not in one chunk?

  • Compaction (like disk defragmentation)
    • What happens if a process needs to grow?

pp

p

g

  • What do we have to do when a process

terminates?

  • Would like to “spread” a process across

RAM if necessaryRAM if necessary

Paging

Paging

Address Translation in Paging System

Data Structures NeededData Structures Needed

• Page table

  • one per process– associate page w/ frame– pointer to table in PCB

• Frame table

  • track free/occupied frames (e.g. w/

bitmap)

Addr. Trans. – 2 Level

Page Size

  • Factors to consider:
      1. internal fragmentation
    1. internal fragmentation

small pages : less IFsmall pages : more pages/process

  • larger page tables

larger page tables

    1. secondary memory

large pages : more efficient xferslarge pages : more efficient xfers

    1. effect on page fault rate

l^

f l

l^

k

as page size increases, principle of locality weakensfewer pages available in memory (More on this later)

    1. program complexity

OOP, threads reduce locality