Lecture 10 homework: Initializing User Process Address Spaces

Handed out: Wednesday, September 29, 2004
Due: Wednesday, October 13, 2004
Read: remainder of Lions' chapter 12 and the relevant source code.

Hand-In Procedure

You are to turn in this homework during lecture. Please write up your answers to the exercises below and hand them in to a 6.828 staff member by the end of the lecture.

Introduction

In this homework you will investigate how exec() sets up the user address space for a new process.

Setting up an Address Space

Boot up the unmodified unix kernel in the PDP-11 simulator and skip to just before the first time line 3172 (exec()'s second call to estabur() in 'sys1.c') is executed. The following commands should allow you to do this:


athena% pdp11
 
PDP-11 simulator V2.3d
sim> de BREAK 33172
sim> at rk0 v6root
sim> boot rk0
@unix
 
Breakpoint, PC=033172  (JSR PC,@#4620)
R0=074640 R1=141666 R2=105532 R3=066064 R4=000017 R5=141726
KSP=141672 USP=000000 PSW=030000 (CM=0,PM=3,IPL=0,tnzvc)

(Using the 'v6 db unix' command, we find that the instructions for exec() (kernel symbol _exec)begin at location 32106. Disassembling the procedure, we find that the first 'JSR PC, 4620' is at memory address 32636 -- the first instruction of estabur() lies at memory location 4620 and the final instruction lies at memory location 5456. Memory address 32636 corresponds to line 3118 in 'sys1.c'. More dissassembly shows that memory address 33172 corresponds to line 3152 in 'sys1.c', explaining why we deposit that value in BREAK above.)

Now execute this call to estabur() so that the user segmentation addresses can be set up as intended:

sim> de BREAK 33176
sim> cont

Breakpoint, PC=033176  (ADD #6,SP)
R0=000000 R1=141660 R2=105532 R3=066064 R4=000017 R5=141726
KSP=141672 USP=000000 PSW=030010 (CM=0,PM=3,IPL=0,tNzvc)

Exercise 1. Draw the prototype segmentation registers and explain their contents after the call to estabur() on line 3152 has completed as above. Also, explain the values sureg() stores in the hardware segmentation register.

You can view the user segmentation registers using the 'ex uipar0-uipdr7' command; similarly, you can view the kernel segmentation registers using 'ex kipar0-kipdr7'.

Exercise 2.Draw a picture of a user address space, and how the kernel maps it into physical memory. The simulator, the figures in chapter 7 and the explanation of exec() in Chapter 12 may be helpful.

This completes the homework.