clippersdogheartedΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

95 εμφανίσεις

Memory management

Instruction execution cycle

Fetch instruction from main memory

Decode instruction

Fetch operands (if needed0

Execute instruction

Store result in memory if needed

At least one memory access per instruction!

Process of compiling, linking and

Compiling: Take program high level
language and convert into object programs

Linker: Take several object programs,
resolve external references and perform
relocation; result: load module

Loader: loads load module in memory

Kinds of addresses

Source program

Object module

Running program

Symbolic addresses

Relocatable addresses

Absolute address

I. Simple memory allocation

Only 1 user.

Partition into two parts
OS part and user

Have bounds register (has smallest
permitted address for user program)

OS can access entire memory; user can
access only user part (except through some
trap instructions)

II. Static partitioned allocation

Memory is divided into a fixed number of
user partitions (plus an OS partition).

Number and size of individual partitions do
not change.

Managing storage


Managing storage

Maintain a table

Location, size and status (in use or free)

Deallocation: Set status to free

Executed when a process terminates and its
memory is to be freed


Search for the partition that is free and is
big enough for the program that needs it.

Two searching schemes

fit: Search table equentially for the first
free partition of sufficient size

search: Search for the smallest free
partition of sufficient size

Dynamic partitioned allocation

Number of size of partitions will vary with

Initially, one big free partition.


Managing memory



Managing memory

Maintain a linked list of free space.

Update the list when doing deallocation or


Insert the partition into the free list.

Merge with adjacent free partition(s) if


First fit allocation

Search list and find the first free partition that is
sufficiently large for the requested process

Best fit allocation algorithm

Find the smallest free partition that is sifficient

Worst fit

Find the largest free partition (not good in

External fragmentation

Free memory is partitioned into large
number of small spaces; cannot allocate to a
process that needs it.

In terms of the extent of external
fragmentation, there is no clear choice
between first fit and best fit; There are
instances when one is better than the other


Move free memory together to make one
large free partition

Moving programs is expensive (moving
time is proportional to program size)

Determining the optimal way to move
programs: NP
hard problem


Break the program into modules (based on
how the program is written; use compiler

Allocate each module separately.

Fragmentation problem is smaller since we
do not have large program sizes

Dynamic address translation in

Each address is of the form (s,o) where s is
the segment number and o is the offset.

At run time, find the beginning absolute
address of segment s, check that offset o is
less than or equal to segment size and

absolute address = starting address+o

Dynamic address translation

Use the segment table

if there are n segments (modules) for a
program, the table has n rows

Each row has two components: size and starting
address of that segment in main memory