Lecture 11 homework: IPC in Unix v6

Handed out: Saturday, October 16, 2004
Due: Monday, October 18, 2004
Read: chapters 13 and 21 of Lions plus 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, briefly, how signals are used in the unix code we've been studying. Particularly, we'll trace through the kill utility telling a process it's been killed.

Kill'ing Another Process

Boot up the unmodified unix kernel in the PDP-11 simulator and login as root.


athena% pdp11

PDP-11 simulator V2.3d
sim> at rk0 v6root
sim> boot rk0
@unix

login: root
# ps -aux
TTY  PID COMMAND
?:     0 3??j??
?:     1 /etc/init
       8 -
       9 ps -aux
?:     5 /etc/update
#_

Now press Ctrl+E together to break into the simulator.

We will set a breakpoint just inside the psig() procedure from unix/sig.c on line 4050. We want to see what signal code will be responded to when we invoke kill.


#
Simulation stopped, PC: PC=015640  (BHI 15646)
R0=140004 R1=015604 R2=064164 R3=000200 R4=000035 R5=141724
KSP=141714 USP=177756 PSW=030000 (CM=0,PM=3,IPL=0,tnzvc)

sim> de break 23144
sim> cont
kill -9 5

Breakpoint, PC=023144  (CLRB 3(R2))
R0=023134 R1=141734 R2=XXXXXX R3=000000 R4=XXXXXX R5=141742
KSP=141732 USP=177764 PSW=030000 (CM=0,PM=3,IPL=0,tnzvc)

R4 above contains the signal code (the current proc's p_sig) and R2 contains the address of the proc structure for the currently executing process (equivalently: the contents of u.u_procp).

(More disassembly: We are stopped right before line 4050; R2 is used for rp; R4 is used for n; and R0 is later used for p.)

Now answer the following questions.

Exercise 1.What process is currrently executing at the breakpoint? What is its process ID?

Hint: The process ID field in the proc structure is stored 10 bytes into the structure. So examine the memory at the location determined by the base address (R2) plus 10 (12 in octal!).

Exercise 2.What signal code was sent to this process? Look at param.h to see what signal this represents.

Remember: simulator outputs octal. Are param.h constants in octal?

Exercise 3.Why was this signal code sent to this process?

This completes the homework.