Chapter 8 (Note 2)
Chapter 8 (Note 2)
2. Memory Protection
The relocation-register scheme provides an effective way to allow the
operating system’s size to change dynamically. This flexibility is desirable in many
situations. The operating system contains code and buffer space for device drivers.
If a device driver (or other operating-system service) is not commonly used, we do
not want to keep the code and data in memory, as we might be able to use that
space for other purposes. Such code is sometimes called transient operating-system
code.
3. Memory Allocation
One of the simplest methods 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 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. Eventually, as you will see, memory contains a set of
holes of various sizes.
The first-fit, best-fit, and worst-fit strategies are the ones most commonly
used to select a free hole from the set of available holes.
• First fit. Allocate the first hole that is big enough. Searching can start either
at the beginning of the set of holes or at the location where the previous first-fit
search ended.
• Best fit. Allocate the smallest hole that is big enough. We must search the
entire list, unless the list is ordered by size. This strategy produces the smallest
leftover hole.
• Worst fit. Allocate the largest hole. Again, we must search the entire list,
unless it is sorted by size. This strategy produces the largest leftover hole, which
may be more useful than the smaller leftover hole from a best-fit approach.
Both first fit and best fit are better than worst fit in terms of decreasing time
and storage utilization.
4. Fragmentation
Both the first-fit and best-fit strategies for memory allocation suffer from
external fragmentation. As processes are loaded and removed from memory, the
free memory space is broken into little pieces. The memory allocated to a process
may be slightly larger than the requested memory. The difference between these
two numbers is internal fragmentation—unused memory that is internal to a
partition.
One solution to the problem of external fragmentation is compaction. The
goal is to shuffle the memory contents so as to place all free memory together in
one large block. It is possible only if relocation is dynamic and is done at execution
time.
5. Paging
Paging is a memory-management scheme that permits the physical address
space of a process to be noncontiguous. Every address generated by the CPU is
divided into two parts: a page number (p) and a page offset (d). The page number
is used as an index into a page table. The page table contains the base address of
each page in physical memory. This base address is combined with the page offset
to define the physical memory address that is sent to the memory unit.
6. Segmentation
Segmentation is a memory-management scheme that supports this
programmer view of memory. A logical address space is a collection of segments.
Each segment has a name and a length. The addresses specify both the segment
name and the offset within the segment. The programmer therefore specifies each
address by two quantities: a segment name and an offset. For simplicity of
implementation, segments are
numbered and are referred to by a
segment number, rather than by a
segment name. Thus, a logical
address consists of a two tuple:
<segment-number,
offset>
An implementation to map two-dimensional user-defined addresses into
one-dimensional physical addresses. This mapping is effected by a segment table.
Each entry in the segment table has a segment base and a segment limit. The
segment base contains the starting physical address where the segment resides in
memory, and the segment limit specifies the length of the segment.
Chapter 8
1. Address Binding
2. Logical Versus Physical Address Space
3. Swapping
4. Contiguous Memory Allocation (5 marks)
5. Fragmentation (5 marks)
6. Paging
7. Segmentation