0% found this document useful (0 votes)
5 views26 pages

L-10

The document discusses storage management and the hierarchy of storage components, highlighting the trade-offs between price, speed, and size as one moves up the hierarchy. It explains the differences between relocatable and non-relocatable programs, memory management techniques, and various allocation strategies such as fixed and dynamic partition allocation. Additionally, it addresses issues of fragmentation and protection mechanisms in memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views26 pages

L-10

The document discusses storage management and the hierarchy of storage components, highlighting the trade-offs between price, speed, and size as one moves up the hierarchy. It explains the differences between relocatable and non-relocatable programs, memory management techniques, and various allocation strategies such as fixed and dynamic partition allocation. Additionally, it addresses issues of fragmentation and protection mechanisms in memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

PART II

STORAGE MANAGEMENT
The Storage Hierarchy
Tapes CD’s
Disk

Main Memory

L3 (optional)
L2

L1
CPU
Properties

Price/byte goes down as you move up the hierarchy:


L1 > L2 > L3 > Main memory > Disk > Tapes
Speed goes down as well:
L1 > L2 > L3 > Main memory > Disk > Tapes
Trends:
CPU getting much faster than storage
The space-time complexity is inherent
Properties: Speed

L1 access time is 1 or 2 CPU cycles


L2 access time is in 10’s of CPU cycles
Main memory access time in the 10’s of ns
Disk access time is in msec
CD ROM access time is in 10’s of msec
Tape access time is in seconds or minutes
Properties: Sizes

L1: 8 to 64K bytes


L2: 256K to 2M bytes
L3: 2M to 32M bytes
Main memory: 16M to 4G bytes
Disks: 1G to 16G bytes
Tapes: Tera bytes
Fact

You can:
Increase size and maintain same speed
Increase speed and maintain same size
BUT
Generally, you cannot do both at a reasonable cost
Programmer’s View

Memory is an array of bytes


It is addressable in a linear fashion:
e.g. For a machine that has a 32-bit address space, memory is an array
from 0 to 232 - 1
Memory cannot hold values between program runs (or when
machine powered down)
NonRelocatable Programs

Programs written such that:


They must be loaded and run at some specific address or
specific range, and/or
Assume some specific region in memory will be theirs
Relocatable Programs

Programs written such that:


They do not assume anything about where they will be loaded,
and do not assume anything about where the data are
placed
A linker can prepare them to run anywhere
Example:
UNIX, Windows NT, OS/2…
Relocatable vs. Nonrelocatable

ld r0, 0x8000 ld r0, *8000


add r0, 4 add r0, 4
ld 0x8004, r0 ld *8004, r0

this assumes data at locations this tells linker data should be


0x8000 and 0x8004 fetched from offsets
Implementing Relocation

Through a relocating linker


Through a relocating loader
Through a relocation register
A Relocating Linker

The linker
knows where the program will run
reads program and translates the addresses
Example:
ld r0, *8000 --> ld r0, 0x10008000
add r0, 4 --> addr0, 4
ld *8004, r0 --> ld 0x10008004, r0
A Relocating Loader

The same as a relocating linker, except that it resolves the


references at load time.
More flexible, no need to know where program will run
beforehand
More overhead, because it had to be done every time the
program is run
Relocation Register

All addressing is relative to a base register


Program can be relocated by changing the value of the base
register
Example:
ld r0, br(8000)
add r0, 4
ld br(8004), r0
Memory Management

Enable programmers to use memory


Protect programs from one another
Manage the physical resources efficiently
Early Systems

Not much of an operating system


Not much memory
Program + monitor
No protection, or relocation User
Example: Program
DOS

Monitor
Overlaying

To overcome limited memory space:


Program written in pieces
After each piece finishes, it “loads” next piece and runs it
Code in one overlay cannot access data or code in another
overlay without loading it
Can be very interesting to program (don’t try this at home!)
Example

Overlay 2 Overlay 1 Overlay 3

Overlay control
On disk
Monitor
Multiple Partition Allocation

Memory grew larger


We want to have more programs in main memory at the same
time
Thus:
Create multiple partitions in main memory
Allocate one partition to each program
Fixed Partition Allocation

Divide memory into Partition 1


partitions of fixed sizes
Load a program into a
partition Partition 2
A program in a partition
cannot access code in
another partition Partition 3
Internal Fragmentation

A program rarely fits Partition 1


exactly into a partition

Partition 2

Partition 3
Program

This fragment is
wasted
Protection: Limit Registers

In addition to the base register, we can have a limit register or a


length register

base register every access


is checked in
hardware to
Program
ensure it is
within the
allowable limits
limit register
Dynamic Partition Allocation

Allocate memory depending on requirements


Partitions adjust depending on memory size
Requires relocatable code
Works best with relocation registers
Dynamic Partition Allocation

Program 1

Program 2

Program 3
External Fragmentation

Program 1

These fragments
are not allocated
to any program,
and they are Program 2
wasted.

Program 3
Compaction (Burping)

Program 1 Program 1

Program 2
Program 2
Program 3

Program 3

You might also like