Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

COMPUTER

ARCHITECTURE 1
Memory Systems
A. S. Bah

BSc Information Systems – IPAM 1


Topics

Introduction

Levels of the Memory Hierarchy

Memory Hierarchy

Cache Memory

Basic Caching Concepts

Virtual Memory

Basics

VM Benefit

BSc Information Systems – IPAM


2
Introduction
Memory access time is important to performance!
Users want large memories with fast access times  ideally
unlimited fast memory
To use an analogy, think of a bookshelf containing many
books:
 Suppose you are writing a paper on butterfly. You go to the bookshelf, pull out some of the
books on butterfly and place them on the desk. As you start to look through them you
realize that you need more references. So you go back to the bookshelf and get more books
on butterfly and put them on the desk. Now as you begin to write your paper, you have
many of the references you need on the desk in front of you.
This is an example of the principle of locality:
This principle states that programs access a relatively small portion of
their address space at any instant of time.

BSc Information Systems – IPAM


3
Introduction
When an operating system manages the
computer’s memory, there are two broad tasks to be
accomplished:
Each process must have enough memory in
which to execute, and it can neither run into the
memory space of another process nor be run into
by another process
The different types of memory in the system must
be used properly so that each process can run
most effectively

BSc Information Systems – IPAM


4
Levels of the Memory Hierarchy
 Part of The On-
 CPU
chip CPU
Datapath
 ISA 16-128  Farther away from
Registers  Registers  the CPU:
 One or more levels (Static RAM):
 Level 1: On-chip 16-64K  Lower Cost/Bit
 Level 2: On-chip 256K-2M  Cache
 Higher Capacity
 Level 3: On or Off-chip 1M-16M  Level(s)  Increased Access
 Dynamic RAM (DRAM)  Time/Latency
 256M-16G  Main Memory  Lower Throughput/
 Bandwidth
 Interface:
 SCSI, RAID,
 IDE, 1394
Magnetic Disc
 80G-300G

 Optical Disk or Magnetic Tape

BSc Information Systems – IPAM 5


Memory Hierarchy Comparisons
Capacity
Access Time faster
Cost Staging
Xfer Unit
CPU Registers
Registers
100s Bytes
<10s ns
Instr. Operands prog./compiler
1-8 bytes
Cache
K Bytes Cache
10-100 ns
1-0.1 cents/bit
cache cntl
Blocks 8-128 bytes
Main Memory
M Bytes Memory
200ns- 500ns
$.0001-.00001 cents /bit OS
Pages 4K-16K bytes
Disk
G Bytes, 10 ms
(10,000,000 ns) Disk
10-5- 10 cents/bit
-6
user/operator
Files Mbytes
Tape Larger
infinite
sec-min Tape
10 -8

BSc Information Systems – IPAM 6


Memory Hierarchy
 We can exploit the natural locality in programs by implementing the
memory of a computer as a memory hierarchy.
 Multiple levels of memory with different speeds and sizes.
 The fastest memories are more expensive, and usually much smaller in size (see figure).
 The user has the illusion of a memory that is both large and fast.
 Accomplished by using efficient methods for memory structure and organization

BSc Information Systems – IPAM 7


Cache Memory
 Processor does all memory
Processor operations with cache.
 Miss – If requested word is not
Words in cache, a block of words
containing the requested word
is brought to cache, and then
Cache
the processor request is
small, fast memory completed.
 Hit – If the requested word is

blocks
in cache, read or write
operation is performed directly
in cache, without accessing
Main memory main memory.
large, inexpensive  Block – minimum amount of
(slow) data transferred between cache
and main memory.
BSc Information Systems – IPAM 8
Basic Caching Concepts
 Memory system is organized as a
hierarchy with the level closest to the
processor being a subset of any level
further away, and all of the data is
stored at the lowest level (see figure).
 Data is copied between only two

adjacent levels at any given time. We


call the minimum unit of information
contained in a two-level hierarchy a
block or line. See the highlighted
square shown in the figure.
 If data requested by the user appears

in some block in the upper level it is


known as a hit. If data is not found in
the upper levels, it is known as a miss.

BSc Information Systems – IPAM 9


Virtual Memory
Some facts of computer life…
Computers run lots of processes simultaneously
No full address space of memory for each process
Must share smaller amounts of physical memory
among many processes
Virtual memory is the answer!
Divides physical memory into blocks, assigns them
to different processes

BSc Information Systems – IPAM 10


Virtual Memory
Virtual memory (VM) allows main memory (DRAM) to act like
a cache for secondary storage (magnetic disk).
provides a mapping from the virtual address of the processor to
the physical address in main memory or on disk.

Compiler assigns data to a “virtual” address.


VA translated to a real/physical somewhere in memory…

(allows any program to run anywhere;


where is determined by a particular machine, OS)

BSc Information Systems – IPAM 11


Virtual Memory Basics
Programs reference “virtual” addresses in a non-existent
memory
 These are then translated into real “physical” addresses
 Virtual address space may be bigger than physical address space
Divide physical memory into blocks, called pages
 Anywhere from 512 to 16MB (4k typical)
Virtual-to-physical translation by indexed table lookup
 Add another cache for recent translations
Invisible to the programmer
 Looks to your application like you have a lot of memory!

BSc Information Systems – IPAM 12


VM Benefit
VM provides the following benefits
Allows multiple programs to share the same physical
memory
Allows programmers to write code as though they have a
very large amount of main memory
Automatically handles bringing in data from disk

BSc Information Systems – IPAM 13


?

BSc Information Systems – IPAM 14

You might also like