3 Points About Overlays
3 Points About Overlays
To enable a process to be larger than the amount of memory allocated to it, we can use overlays.
The idea of overlays is to keep in memory only those instructions and data that are needed at any
given time. When other instructions are needed, they are loaded into space occupied previously by
instruction that are no longer needed.
The relocation register contains the value of the smallest physical addresses; the limit register
contains the range of logical addresses. With relocation and limit registers, each logical address
must be less than the limit register; the MMU maps the logical address dynamically by adding the
value in the relocation register which is sent to memory.
When CPU selects a process for execution, the dispatcher loads the relocation and limit registers
with the correct values as part of the context switch.
Memory Allocation
Here are the methods for allocating memory
• One of the simplest ways for allocating memory is to divide memory into several fixed-
sized partitions. Each partition may contain exactly one process. Thus the degree of
multiprogramming is bound by the number of partitions. In this method when a partition is
free, a process is selected from the input queue and is loaded into the free partition. When the
process terminates, the partition become available for another process.
• In the variable-partition scheme, the operating system keeps a table indicating which parts
of memory are available and which are occupied. Initially, all memory is available for user
processes, and is considered one large block of available memory, a hole.
• An alternate approach is to keep a list of unused ( free ) memory blocks ( holes ), and to find
a hole of a suitable size whenever a process needs to be loaded into memory. There are many
different strategies for finding the "best" allocation of memory to processes, including the
three most commonly discussed:
1. First fit - Search the list of holes until one is found that is big enough to satisfy the
request, and assign a portion of that hole to that process. Whatever fraction of the
hole not needed by the request is left on the free list as a smaller hole. Subsequent
requests may start looking either from the beginning of the list or from the point at
which this search ended.
2. Best fit - Allocate the smallest hole that is big enough to satisfy the request. This
saves large holes for other process requests that may need them later, but the
resulting unused portions of holes may be too small to be of any use, and will
therefore be wasted. Keeping the free list sorted can speed up the process of finding
the right hole.
3. Worst fit - Allocate the largest hole available, thereby increasing the likelihood that
the remaining portion will be usable for satisfying future requests.
• Simulations show that either first or best fit are better than worst fit in terms of both time and
storage utilization. First and best fits are about equal in terms of storage utilisation, but first
fit is faster.