Beruflich Dokumente
Kultur Dokumente
Chapter 7
Background
Operating system responsibilities
Bring program into memory and place it in a process
for it to be executed.
Ensure adequate storage for processes
Maintain an input queue (collections of processes on
disk waiting to be brought into main memory)
Bind instructions and data to memory addresses
At compile time- if memory location is known
At loading time- if memory location is not known at compile
time, the compiler generates relocatable code bound at load
time &
Execution time- if process can be moved between segments
during execution.
Dynamic loading (DL)
User
Single Partition Allocation
To protect the operating system from changes by
user processes, we implement relocation
registers with a limit register.
The relocation register contains the smallest
value of the smallest physical address.
The limit register contains the range of logical
addresses.
Each logical address must be less than the limit
register.
MMU maps the logical address dynamically by
adding the value in the relocation register
Hardware support for Relocation &
Limit registers.
Limit Relocation
register register
Memory
yes Physical
Logical
CPU address < +
address
Trap
Multiple Partition Allocation
Fixed partitions
Divide memory into a number of fixed-sized partitions.
Each partition contains exactly one process
When a partition is free a process small enough to fit
the hole is selected from the input queue and loaded,
on completion it frees the partition for other
processes.
Hole is a block of available memory.
List of available holes
Disadvantages
Process smaller then partitions waste space.
Some partitions may never be used too small or too big
Variable Partions
Varying number of processes and
partitions.
Can fit many processes in a single hole
Complicated allocation and deallocation
Difficult to keep track of memory
Results in creation of many unusable
holes.
Solution use compaction
Compaction
Shuffling memory contents to place all free
memory together in one large block.
Possible only if relocation is dynamic and
is done at execution time
Keeping Track of Memory
Use
Bit Maps
Linked Lists- Dynamic Storage allocatio
Buddy System
Bit Maps
Memory divided into small units
1 bit in a map per unit
0 means unit not occupied
1 means unit occupied
If a process requests n units , memory manager looks for
consecutive 0s in the map.
Example
0 0 1 1 1
0 1 1 0 0
0 0 0 1 0
1 0 0 1 1
Linked Lists
Problem how to satisfy a request of size n from a list of
free holes?
Keep a linked list of allocated & free memory blocks
First-Fit: allocate the first hole big enough.
Next-Fit : Scan memory region list from point of last
allocation to next fit.
Best-Fit: allocate the smallest hole big enough.
Worst-Fit: allocate the largest hole.
Quick fit- maintains list for each common size requests
List for 8k holes, list for 16k holes, list for 32k holes.
Determine suitable list and fit process
Example
Given the following, use the best, worst and first fit
algorithms to allocate memory to the different
processes.
Process
Memory need
500k 212K
200K 417K
300K 112K
600K 426K
First Fit