lecture notes

mangledcobwebSoftware and s/w Development

Dec 14, 2013 (4 years and 18 days ago)

69 views

Rensselaer Polytechnic Institute

CSCI
-
4210


Operating Systems

David Goldschmidt, Ph.D.

very small

very large

very fast

very slow

volatile

non
-
volatile


Based on the
von Neumann architecture
,
data and program instructions

exist in physical memory


Repeatedly perform

fetch
-
decode
-
execute

cycles


The
execute

part

often results in
data

fetch

and
store

operations


Locations in memory

are identified by

memory addresses



When compiled, programs

consist of
relocatable code



Other compiled modules

also consist of

relocatable code


At
load time
, any

additional libraries

also consist of

relocatable code



At
run time
, memory

addresses of all object

files are mapped to a

single memory space

in
physical memory



Using
dynamic loading
, external libraries are
not loaded when a process starts


Libraries are stored on disk in
relocatable

form


Libraries loaded into memory only when needed



Using
dynamic linking
, external libraries can
be preloaded into shared memory


When a process calls a library function, the

corresponding physical address is determined


Main memory

is
partitioned

and allocated

to resident

operating system

and user processes

fixed partitioning scheme


A pair of
base

and
limit

registers define the

logical address space



Also known as

relocation registers



The CPU generates logical memory addresses


A
Memory
-
Management Unit

(
MMU
)

maps logical memory addresses

to the
physical address space








User programs never see

physical memory addresses


Hardware protects against memory access
outside of a process’s valid memory space


Variable
-
length or
dynamic

partitions:


When a new process enters the system, the
process is allocated to a single contiguous block









The operating system maintains a list of
allocated partitions and free partitions

OS

Process 5

Process 8

Process 2

OS

Process 5

Process 2

OS

Process 5

Process 2

Process 9

OS

Process 5

Process 9

Process 2

Process
1


How can we place new process P
i

in memory?


First
-
fit algorithm
: allocate the first free block

that’s large enough to accommodate P
i



Best
-
fit algorithm
: allocate the

smallest free block that’s large

enough to accommodate P
i



Next
-
fit algorithm
: allocate the

next free block, searching from last allocated block


Worst
-
fit algorithm
: allocate the largest free block

that’s large enough to accommodate P
i



Memory is wasted due to
fragmentation
,

which can cause performance issues


Internal fragmentation

is wasted memory

within

a partition or process memory


External fragmentation

can reduce

the number of runnable processes


Total memory space exists to satisfy

a memory request, but memory is

not contiguous

OS

Process 5

Process 8

Process 2

Process 3

Process 6

Process 12

Process 7

Process 9

Process 3

Process 6

Process 12

Process 7


Reduce external fragmentation by

compaction

or
defragmentation



Rearrange memory contents to organize

all free memory blocks together into

one large contiguous block


Compaction is possible only if

relocation is dynamic and is

done at execution time


Compaction is expensive

OS

Process 5

Process 8

Process 2

Process 9

Process 3

Process 6

Process 12

Process 7

Process 3

Process 6

Process 12

Process 7

Process 9