7.9 An Example

Consider a program on the PDP11/40 which uses 1.7 pages of text, 3.3 pages of data, and 0.7 pages of stack area. (Our use of fractions in this example is admittedly a little crude.) The set of virtual addresses would be divided as shown in the following diagram:

888 s1

Stack

888 s1

area

888

 

777

 

777

 

777

 

666

 

666

 

666 d4

 

555 d3

 

555 d3

 

555 d3

 

444 d2

Data

444 d2

 

444 d2

area

333 d1

 

333 d1

 

333 d1

 

222

 

222 t2

 

222 t2

Text

111 t1

 

111 t1

area

111 t1

 

Virtual Address Space

Two whole pages in the virtual address space must be allocated to the text segment, even though the physical area required is only 1.7 pages.

222 t2

 

222 t2

Text

111 t1

 

111 t1

area

111 t1

 

Text Segment

The data and stack areas require the dedication of four and one pages of virtual address space, and 3.3 and 0.7 pages of physical memory respectively.

The whole data segment requires four and one eighth pages of physical memory. The extra eighth is for the “per process data area” which corresponds (from time to time) to the seventh kernel address page.

888 s1

Stack

888 s1

area

666 d4

 

555 d3

 

555 d3

 

555 d3

 

444 d2

Data

444 d2

 

444 d2

area

333 d1

 

333 d1

 

333 d1

 

ppda

 

Data Segment

Note the order of the components of the data segment, and that there is no embedded unused space.

The user mode segmentation need to be set to reflect the values in the following table, where “t”, “d” denote the block numbers of beginning of the text and data segments respectively:

Page

Address

Size

Comment

1

t+0

1.0

read only

2

t+128

0.7

read only

3

d+16

1.0

 

4

d+144

1.0

 

5

d+272

1.0

 

6

d+400

0.3

 

7

?

0.0

not used

8

d+400

0.7

grows downward

Note the setting of the eighth address register. The address prototypes stored in the array “u.u_uisa” are obtained by setting “t” and “d” to zero.