Virtual Memory I CSE410, Winter 2017, Lecture notes of Algorithms and Programming

Virtual memory and its management in the context of CSE410 course in Winter 2017. It covers topics such as memory allocation, physical memory management, and indirection. It also briefly mentions the Amazon AWS S3 outage and its impact on websites and apps. administrative information such as lab and homework deadlines, final exam date, and review session. The document could be useful as study notes or lecture notes for a university student preparing for an exam or assignment in a computer science course related to operating systems or memory management.

Typology: Lecture notes

2016/2017

Uploaded on 05/11/2023

alopa
alopa šŸ‡ŗšŸ‡ø

4.2

(19)

255 documents

1 / 36

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE410, Winter 2017L22: Virtual Memory I
VirtualMemoryI
CSE410Winter2017
Instructor: TeachingAssistants:
JustinHsia KathrynChan,KevinBi,RyanWong,WaylonHuang,Xinyu Sui
Amazon AWS S3 outage is breaking things for a lot of websites and apps
Amazon’s S3 web-based storage service is experiencing widespread issues, leading to
service that’s either partially or fully broken on websites, apps and devices upon which it
relies. Connected lightbulbs, thermostats and other IoT hardware is also being impacted,
with many unable to control these devices as a result of the outage.
It’s used by 0.8 percent of the top 1 million websites, which is
actually quite a bit smaller than CloudFlare, which is used by 6.2
percent of the top 1 million websites globally – and yet it’s still
having this much of an effect.
•https://techcrunch.com/2017/02/28/amazon‐aws‐s3‐outage‐is‐breaking‐things‐for‐a‐
lot‐of‐websites‐and‐apps/
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download Virtual Memory I CSE410, Winter 2017 and more Lecture notes Algorithms and Programming in PDF only on Docsity!

CSE410, Winter 2017

L22: Virtual Memory I

Virtual Memory I CSE 410 Winter 2017 Instructor:

Teaching Assistants:

Justin Hsia

Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui

Amazon AWS S3 outage is breaking things for a lot of websites and apps Amazon’s S3 web-based storage service is experiencing widespread issues, leading toservice that’s either partially or fully broken on websites, apps and devices upon which itrelies. Connected lightbulbs, thermostats and other IoT hardware is also being impacted,with many unable to control these devices as a result of the outage.It’s used by 0.8 percent of the top 1 million websites, which isactually quite a bit smaller than CloudFlare, which is used by 6.2percent of the top 1 million websites globally – and yet it’s stillhaving this much of an effect. •^ https://techcrunch.com/2017/02/28/amazon‐aws‐s3‐outage‐is‐breaking‐things‐for‐a‐lot‐of‐websites‐and‐apps/

CSE410, Winter 2017

L22: Virtual Memory I

Administrivia^ ^ Lab 4 due next Tuesday (3/7)^ ^ Homework 5 released today, due next Thursday (3/9)^ ^ Optional Section: Processes, VM Intro^ ^ Final Exam:

Tuesday, March 14 @ 2:30pm (MGH 241) ļ‚§^ Review Session: Sunday, March 12 @ 1:30pm in SAV 264 ļ‚§^ Cumulative (midterm clobber policy applies) ļ‚§^ TWO double‐sided handwritten 8.

11ā€ cheat sheets

-^ Recommended that you reuse or remake your midterm cheat sheet

CSE410, Winter 2017

L22: Virtual Memory I

Virtual Memory (VM*)^ ^ Overview and motivation^ ^ VM as a tool for caching^ ^ Address translation^ ^ VM as a tool for memory management^ ^ VM as a tool for memory protection

*Not to be confused with ā€œVirtual Machineā€ which is a whole other thing.

Warning:

Virtual memory is pretty complex, but crucial for understanding how processeswork and for debugging performance

CSE410, Winter 2017

L22: Virtual Memory I

Memory as we know it so far… is

virtual!

^ Programs refer to virtual memory addresses^ ļ‚§^ movq (%rdi),%rax^ ļ‚§^ Conceptually memory is just a very large array of bytes^ ļ‚§^ System provides private address space to each process ^ Allocation: Compiler and run‐time system^ ļ‚§^ Where different program objects should be stored^ ļ‚§^ All allocation within single virtual address space ^ But…^ ļ‚§^ We

probably

don’t have

w^2 bytes of physical memory

ļ‚§^ We^ certainly

don’t have

w^2 bytes of physical memory

for every process ļ‚§ Processes should not interfere with one another^ •^ Except in certain cases where they want to share code or data

0xFFāˆ™āˆ™āˆ™āˆ™āˆ™āˆ™F 0x00āˆ™āˆ™āˆ™āˆ™āˆ™āˆ™

CSE410, Winter 2017

L22: Virtual Memory I

Problem 2: Memory Management

Physical main memory

What goeswhere?

stackheap .text.data^ …

Process 1Process 2Process 3… Process n

Each process has…x

We have multipleprocesses:

CSE410, Winter 2017

L22: Virtual Memory I

Problem 3: How To Protect

Physical main memory

Process^

i

Process^

j

Problem 4: How To Share?

Physical main memory

Process^

i

Process^

j

CSE410, Winter 2017

L22: Virtual Memory I

Indirection^ ^ ā€œAny problem in computer science can be solved by addinganother level of indirection.ā€

–David Wheeler, inventor of the subroutine

^ Without Indirection ^ With Indirection

P^

Thing

P^

Thing

What if I want to move Thing?

P1 P3 P1 P

NewThing^ NewThing

CSE410, Winter 2017

L22: Virtual Memory I

Indirection^ ^ Indirection

: The ability to reference something using a name, reference, or container instead of the value itself. A flexiblemapping between a name and a thing allows changing thething without notifying holders of the name.^ ļ‚§^ Adds some work (now have to look up 2 things instead of 1)^ ļ‚§^ But don’t have to track all uses of name/address (single source!)  Examples:^ ļ‚§^ Phone system:

cell phone number portability

ļ‚§^ Domain Name Service (DNS):

translation from name to IP address

ļ‚§^ Call centers:

route calls to available operators, etc.

ļ‚§^ Dynamic Host Configuration Protocol (DHCP):

local network address

assignment

CSE410, Winter 2017

L22: Virtual Memory I

Address Spaces^ ^ Virtual address space: Set of

௔^ virtual addr

ļ‚§^ {0, 1, 2, 3, …,

‐1}

^ Physical address space: Set of

݉ physical addr

ļ‚§^ {0, 1, 2, 3, …,

‐1}

^ Every byte in main memory has:^ ļ‚§^ one physical address (PA)^ ļ‚§^ zero, one,

or more

virtual addresses (VAs)

CSE410, Winter 2017

L22: Virtual Memory I

Mapping^ ^ A virtual address (VA) can be mapped to either physicalmemory or disk^ ļ‚§^ Unused VAs may not have a mapping^ ļ‚§^ VAs from

different

processes may map to same location in memory/disk

Process 2’s VirtualAddress Space

PhysicalMemory Disk

Process 1’s VirtualAddress Space

ā€œSwap Spaceā€

CSE410, Winter 2017

L22: Virtual Memory I

A System Using Virtual Addressing

^ Physical addresses are

completely invisible to programs

ļ‚§^ Used in all modern desktops, laptops, servers, smartphones… ļ‚§^ One of the great ideas in computer science

Main memory0: 1: M‐1:

MMU

Physical address(PA) Data (int/float)

CPU

Virtual address(VA)

CPU Chip

0x

0x4100^ Memory Management Unit

CSE410, Winter 2017

L22: Virtual Memory I

Why Virtual Memory (VM)?^ ^ Efficient use of limited main memory (RAM)^ ļ‚§^ Use RAM as a cache for the parts of a virtual address space^ •

Some non‐cached parts stored on disk • Some (unallocated) non‐cached parts stored nowhere ļ‚§ Keep only active areas of virtual address space in memory • Transfer data back and forth as needed ^ Simplifies memory management for programmers^ ļ‚§^ Each process ā€œgetsā€ the same full, private linear address space ^ Isolates address spaces (protection)^ ļ‚§^ One process can’t interfere with another’s memory^ •

They operate in

different address spaces

ļ‚§^ User process cannot access privileged information^ •^ Different sections of address spaces have different permissions

CSE410, Winter 2017

L22: Virtual Memory I

or:^ Virtual Memory as DRAM Cache for Disk^ ^ Think of virtual memory as an array of

contiguous

bytes stored

on a disk ^ Then physical main memory is used as a

cache

for the

virtual memory array^ ļ‚§^ These ā€œcache blocksā€ are called

pages^ (size is

݌ P ൌ 2

bytes)

m‐p^ PP 2‐ Physical memory^ EmptyEmpty

VP 0VP 1 Uncached n‐p^ VP 2‐ Virtual memory^ UnallocatedCachedUncachedUnallocatedCachedUncached

PP 0PP 1 Empty

Cached

0 N‐

(^0) M‐

Virtual pages (VPs)ā€œstored on diskā€

Physical pages (PPs)cached in DRAM

CSE410, Winter 2017

L22: Virtual Memory I

Memory Hierarchy: Core 2 Duo

Disk

MainMemory

L2unifiedcache L1I‐cache L1D‐cache CPU^ Reg

2 B/cycle 8 B/cycle 16 B/cycle

1 B/30 cycles

Throughput:Latency:

100 cycles 14 cycles 3 cycles^

millions

~4 MB 32 KB

~8 GB^
~500 GB

Not drawn to scale

Miss Penalty(latency)^ 33x

Miss Penalty(latency)^ 10,000x

SRAM

Static Random Access Memory

DRAM

Dynamic Random Access Memory