ch8 - Memory Management
ch8 - Memory Management
Swapping
Paging
Segmentation
Virtual memory
Memory allocation
Monoprogramming:
If a block is freed, we try to merge it with its neighbors if they are also free.
Selection of blocks
There are three main algorithms for searching the list of free blocks
for a specific amount of memory:
First-Fit: Allocate the first free block that is large enough for
the new process (very fast).
before
insertion
Relative performance
1000 1000
P3
800
650
600 P3
P2 450
250 P2
100
100 P1
P1 50
50 OS
OS
Swapping
In a time sharing system, there are more users than there is memory to
hold all their processes. → Some excess processes which are blocked
must be kept on backing store. Moving processes between main
memory and backing store is called swapping.
The main problem with swapping and variable partitions is to keep track
of memory usage. Some techniques to address this issue are:
Bit Maps
Linked lists
Buddy system.
Schematic View of Swapping
Bit Maps Technique
With a bit map, memory is divided up into allocation units
(16-512 bytes). Corresponding to each allocation unit is a
bit in the bit map, which is 0 if the unit is free and 1 if it is
occupied
The main problem with bit maps is searching for consecutive 0 bits
in the map for a process. Such a search takes a long time.
Linked lists Technique
The idea is to maintain a linked list of allocated and free
memory segments, where a segment is either a process or a
hole between two processes. Each entry in the list specifies a
hole (H) or process (P), the address at which it starts, the length
and a pointer to the next entry.
The main advantage of this is that the list can be easily modified
when a process is swapped out or terminates.
Example
Consider the previous system, and assume process C is
swapped out.
H
A new process is added
To allocate memory for a newly created or swapped in process,
First-fit or Best-fit algorithms can be used:
A new process is added
Buddy system technique
EXAMPLE:
Assume we have a paging system which uses associative
registers with a hit ratio of 90%. Assume associative registers
have an access time of 30 nanoseconds, and the memory
access time is 470 nanoseconds. Find the effective memory
access time (emat)
√ √
OPT has the lowest page fault rate for a fixed number of frames
among all the page replacement algorithms.
√ √ √ √ √ √
√ √ √
√
√ √ √
√ √
√ √ √ √