You are on page 1of 6

CS 354 - Machine Organization

Friday, October 7, 2016

Project p2 (6%) due 10 pm TODAY Friday, October 7th


Project p3 (6%) due 10 pm Monday, October 24th (exam week)
Homework hw4 (1.5%) due 10 pm Friday, October 14th
Last Time
Footers
Explicit Free List
Ordering Free Blocks by Address
Today
Ordering Free Blocks by Address (bring updated page)
Ordering Free Blocks by LIFO (bring updated page)
Heap Caveats
Three Faces of Memory
Next Time
Read: B&O 6 intro, 6.2 and 6.3
Memory Hierarchies & Locality

Copyright 2016 Jim Skrentny

CS 354 (F16): L14 - 1

Heap Caveats
Dont assume consecutive heap allocation result in continuous payloads!

 Why?
Dont access uninitialized heap memory!

 Isnt heap memory initialized to 0?


Do free all heap memory that your program allocates!

 Why are memory leaks bad?


 Do memory leaks persist when a program ends?
Dont free heap memory more than once!

 What is the best way to avoid this mistake?


Dont access data in freed heap blocks!

 What kind of error will result?

Dont change heap memory outside of your payload!

 Why?
Do check if your memory intensive program has run out of heap memory!

 How?

Copyright 2016 Jim Skrentny

CS 354 (F16): L14 - 2

Three Faces of Memory


Processs View
Stack

Heap
Uninit Data
Init Data
Code

Hardwares View
L0:
Registers
(in CPU)
L1: Cache
L2: Cache
L3: Cache
(SRAM)
L4: Main Memory
(DRAM)
L5: Local Secondary Storage
(HDD,SSD,DVD)
L6: Network Storage (NAS,Cloud)

Systems View (CS 537)


Process 1
VAS
Main Memory

Process 2
VAS

Process 3
VAS

Copyright 2016 Jim Skrentny

OS
Page
Table

Secondary
Storage 1

Secondary
Storage 2

CS 354 (F16): L14 - 3

Three Faces of Memory - Process

Virtual Memory
Stack

Virtual Address (VA)


Heap
Uninit Data
Init Data
Code

Virtual Address Space (VAS)

Copyright 2016 Jim Skrentny

CS 354 (F16): L14 - 4

Three Faces of Memory - Hardware

Physical Memory
L0:
Registers
(in CPU)
L1: Cache
L2: Cache
L3: Cache
(SRAM)
L4: Main Memory
(DRAM)
L5: Local Secondary Storage
(HDD,SSD,DVD)
L6: Network Storage (NAS,Cloud)

Physical Address (PA)

Physical Address Space (PAS)

Copyright 2016 Jim Skrentny

CS 354 (F16): L14 - 5

Three Faces of Memory - System

Memory Pages
Process 1
VAS
Main Memory

Process 2
VAS

Process 3
VAS

OS
Page
Table

Secondary
Storage 1

Secondary
Storage 2

Why do Operating Systems use Virtual Memory?

Copyright 2016 Jim Skrentny

CS 354 (F16): L14 - 6

You might also like