* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / s05_03.htm
blob4910e57099871dce1b8bf44022a19fddcb8a333f
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Section 5.3</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c05.htm">
8 Chapter 5 -- Memory Management</A><BR>
9 <B>prev:</B> <A HREF="s05_02.htm">5.2 Page Translation</A><BR>
10 <B>next:</B> <A HREF="c06.htm">Chapter 6 -- Protection</A><BR>
11 <P>
12 <HR>
13 <P>
14 <H1>5.3 Combining Segment and Page Translation</H1>
16 <A HREF="#fig5-12">Figure 5-12</A>
17 combines
18 <A HREF="s05_01.htm#fig5-2">Figure 5-2</A>
19 and
20 <A HREF="s05_02.htm#fig5-9">Figure 5-9</A>
21 to summarize both phases
22 of the transformation from a logical address to a physical address when
23 paging is enabled. By appropriate choice of options and parameters to both
24 phases, memory-management software can implement several different styles of
25 memory management.
27 <H2>5.3.1 "Flat" Architecture</H2>
28 When the 80386 is used to execute software designed for architectures that
29 don't have segments, it may be expedient to effectively "turn off" the
30 segmentation features of the 80386. The 80386 does not have a mode that
31 disables segmentation, but the same effect can be achieved by initially
32 loading the segment registers with selectors for descriptors that encompass
33 the entire 32-bit linear address space. Once loaded, the segment registers
34 don't need to be changed. The 32-bit offsets used by 80386 instructions are
35 adequate to address the entire linear-address space.
37 <H2>5.3.2 Segments Spanning Several Pages</H2>
38 The architecture of the 80386 permits segments to be larger or smaller than
39 the size of a page (4 Kilobytes). For example, suppose a segment is used to
40 address and protect a large data structure that spans 132 Kilobytes. In a
41 software system that supports paged virtual memory, it is not necessary for
42 the entire structure to be in physical memory at once. The structure is
43 divided into 33 pages, any number of which may not be present. The
44 applications programmer does not need to be aware that the virtual memory
45 subsystem is paging the structure in this manner.
46 <P>
47 <A NAME="fig5-12">
48 <IMG align=center SRC="fig5-12.gif" border=0>
49 <P>
50 <H2>5.3.3 Pages Spanning Several Segments</H2>
51 On the other hand, segments may be smaller than the size of a page. For
52 example, consider a small data structure such as a semaphore. Because of the
53 protection and sharing provided by segments (refer to
54 <A HREF="c06.htm">Chapter 6</A>
55 ) , it may be
56 useful to create a separate segment for each semaphore. But, because a
57 system may need many semaphores, it is not efficient to allocate a page for
58 each. Therefore, it may be useful to cluster many related segments within a
59 page.
61 <H2>5.3.4 Non-Aligned Page and Segment Boundaries</H2>
62 The architecture of the 80386 does not enforce any correspondence between
63 the boundaries of pages and segments. It is perfectly permissible for a page
64 to contain the end of one segment and the beginning of another. Likewise, a
65 segment may contain the end of one page and the beginning of another.
67 <H2>5.3.5 Aligned Page and Segment Boundaries</H2>
68 Memory-management software may be simpler, however, if it enforces some
69 correspondence between page and segment boundaries. For example, if segments
70 are allocated only in units of one page, the logic for segment and page
71 allocation can be combined. There is no need for logic to account for
72 partially used pages.
74 <H2>5.3.6 Page-Table per Segment</H2>
75 An approach to space management that provides even further simplification
76 of space-management software is to maintain a one-to-one correspondence
77 between segment descriptors and page-directory entries, as
78 <A HREF="#fig5-13">Figure 5-13</A>
80 illustrates. Each descriptor has a base address in which the low-order 22
81 bits are zero; in other words, the base address is mapped by the first entry
82 of a page table. A segment may have any limit from 1 to 4 megabytes.
83 Depending on the limit, the segment is contained in from 1 to 1K page
84 frames. A task is thus limited to 1K segments (a sufficient number for many
85 applications), each containing up to 4 Mbytes. The descriptor, the
86 corresponding page-directory entry, and the corresponding page table can be
87 allocated and deallocated simultaneously.
88 <P>
89 <A NAME="fig5-13">
90 <IMG align=center SRC="fig5-13.gif" border=0>
91 <P>
92 <HR>
93 <P>
94 <B>up:</B> <A HREF="c05.htm">
95 Chapter 5 -- Memory Management</A><BR>
96 <B>prev:</B> <A HREF="s05_02.htm">5.2 Page Translation</A><BR>
97 <B>next:</B> <A HREF="c06.htm">Chapter 6 -- Protection</A><BR>
98 </BODY>