Swapping:
Bring in each process in its entirety, and run it for a whole,
then put it back to disk.
-
Variable Partitions
-
Programs are moved in and out of main memory.
-
Program is swapped to disk if it is interrupted, and there are pending
requests for memory.
-
Save information in the process table.
-
Data segment
-
Local variables
-
Stack segment
How to decide a job in memory or disk?
How to decide which one to swap in?
-
the one waiting long?
-
the one has smallest job?
-
.....
Allocate blocks to processes: (Goal: Reduce fragmentation)
-
Best fit - pick the smallest
block >= the request size.
-
Next fit - pick the next
one after our last allocation that fits.
-
First fit - start at
the bottom & allocate the first that fits.
-
Worst fit - always pick
the biggest.
After swapping, holes in memory will turn to be small. (Fragmentation)
If push all down, there will have space for another process but it takes
CPU time.
Memory Compaction:
Move all program to low
memory resulting in one large empty block in high memory. (It is
too much overhead involved.)