Hardware Reference
In-Depth Information
Try to understand why protection makes sense in a segmented memory but not
in a one-dimensional (i.e., linear) paged memory. In a segmented memory the user
is aware of what is in each segment. Normally, a segment would not contain both a
procedure and a stack, for example, but one or the other. Since each segment con-
tains only one type of object, the segment can have the protection appropriate for
that particular type. Paging and segmentation are compared in Fig. 6-9.
Consideration
Paging
Segmentation
Need the programmer be aware of it?
No
Yes
How many linear addresses spaces are there?
1
Many
Can virtual address space exceed memory size? Yes
Yes
Can variable-sized tables be handled easily?
No
Yes
Why was the technique invented?
To simulate large
memories
To provide multiple ad-
dress spaces
Figure 6-9. Comparison of paging and segmentation.
The contents of a page are, in a sense, accidental. The programmer is unaware
that paging is even occurring. Although putting a few bits in each entry of the
page table to specify the access allowed would be possible, to utilize this feature
the programmer would have to keep track of where in his address space the page
boundaries were. The trouble with this idea is that this is precisely the sort of
administration that paging was invented to eliminate. Because the user of a seg-
mented memory has the illusion that all segments are in main memory all the time,
they can be addressed without having to be concerned with the administration of
overlaying them.
6.1.7 Implementation of Segmentation
Segmentation can be implemented in one of two ways: swapping and paging.
In the former scheme, some set of segments is in memory at a given instant. If a
reference is made to a segment not currently in memory, that segment is brought
in. If there is no room for it, one or more segments must be written to disk first
(unless a clean copy already exists there, in which case the memory copy can just
be abandoned). In a certain sense, segment swapping is not unlike demand paging:
segments come and segments go as needed.
However, the implementation of segmentation differs from paging in a very es-
sential way: pages are of fixed size and segments are not. Figure 6-10(a) shows an
example of physical memory initially containing five segments. Now consider
what happens if segment 1 is evicted and segment 7, which is smaller, is put in its
place. We arrive at the memory configuration of Fig. 6-10(b). Between segment 7
and segment 2 is an unused area—that is, a hole. Then segment 4 is replaced by
segment 5, as shown in Fig. 6-10(c), and segment 3 is replaced by segment 6, as in
 
 
 
Search WWH ::




Custom Search