ECS150 Course Website

last updated
Programming Assignment #3

Lab 3 Announcements

The due date for lab 3 is Tuesday March 16th at 12:00 noon. Interactive grading will be held Tuesday March 16th, Wednesday March 17th, and Thursday March 18th. Signup sheets are outside the Kemper Hall TA room.

You MUST have test programs for part 2 and part 3.

Handin Procedure

You will demonstrate your kernel on my laptop. Therefore you will need to turn in:

  • kernel image
  • test programs

To copy the kernel image, first make sure you have compiled the version of the kernel you want to submit. Then, follow these directions:

  1. mount /dev/fd1 /fd1
  2. cp /minix/2.0.3r* /fd1/lab3/

Next make sure you copy all your test programs to /fd1/lab3/. Then shutdown Minix and compress the virtual floppy image. To do this on a CSIF lab computer use:

zip -v [lastname]-lab3.zip floppy.img

Finally, email the compressed zip file to sjengle@ucdavis.edu with the subject line "ECS150 Lab 3"

Interactive Grading

Interactive grading will take place in the Kemper Hall TA room. Interactive grading sign up sheets for lab 3 are located outside the Kemper Hall TA room. Please sign up ASAP. Grading will occur on:

  • Tuesday March 16th, 4:00pm - 5:30pm
  • Wednesday March 17th, 1:00pm - 5:00pm
  • Thursday March 18th, 1:00pm - 4:30pm

Since interactive grading for this lab occurs at the end of the quarter, I am going to be strict about several issues:

  • ALL group members must be present for interactive grading to begin.
  • All group members must be ON TIME. If any group member is more than 10 minutes late, the entire group may have to reschedule.
  • If the handin instructions are not followed correctly, 5% will be deducted from the final grade.

Hints and Tips

I am posting some hints and tips that may help some people get started. I have to thank all the students that stopped by today to help hash a lot of these problems out (and those students posting on the discussion board).

Also, all the line numbers I provide are the actual line numbers in the Minix source code. This means the line numbers do not correspond to the line numbers the book.

Part 1

First, if you are modifying /usr/src/kernel/tty.c, you will have to test your changes at the login prompt. This means you will have to test your changes when noname login: shows up (before you login to Minix). After you actually login, the shell sh is running (and sh defines its own actions for CTRL-P).

Next, you want to test if the user pressed CTRP-P. I recommend doing this in the function in_process (in tty.c). There are basically two different methods of testing if the user pressed CTRL-P. The easiest way is to make use of the C(c) macro defined in /usr/include/minix/keymap.h. Therefore you should be able to do something like:

if(ch == C('P')) -or-
if(ch == C('p'))

Both if statements worked for me. The second method involves a little bit more work. You should notice that tty.c uses a field c_cc to test for control characters. For example, in the function in_process, you will see the line:

if(ch == tp->tty_termios.c_cc[VERASE])

This actually checks to see if CTRL-H was pressed. We can use a similar method to check for CTRL-P. First, look at /usr/include/termios.h. Notice that c_cc is actually a field in the structure termios (lines 14-21). We will use this knowledge in a little bit.

Now we must define our own entry in c_cc. The indices into the c_cc array are defined on lines 65-75 and on lines 161-163. Lets add our own index VREPLACE on line 164. Since the last index was 13, we should do something like:

#define VREPLACE 14 /* c_cc[VREPLACE] (^P) */

The next step is to define what control sequence VREPLACE actually corresponds to. This is done for all the other control sequences on lines 177 - 193. So we should add another define similar to:

#define TREPLACE_DEF '\20' /* ^P */

The '\20' refers to the octal value for CTRL-P. (Note that some people had to actually use '\16' instead.)

The last step is to initialize c_cc[VREPLACE] to TREPLACE_DEF. We can do this by taking advantage of termios_defaults on line 120 of /usr/src/kernel/tty.c. We just need to add TREPLACE_DEF to the end of the definition, giving us:

PRIVATE struct termios termios_defaults = {
  TINPUT_DEF, TOUTPUT_DEF, TCTRL_DEF, TLOCAL_DEF, TSPEED_DEF, TSPEED_DEF,
  {
		TEOF_DEF, TEOL_DEF, TERASE_DEF, TINTR_DEF, TKILL_DEF, TMIN_DEF,
		TQUIT_DEF, TTIME_DEF, TSUSP_DEF, TSTART_DEF, TSTOP_DEF,
		TREPRINT_DEF, TLNEXT_DEF, TDISCARD_DEF, TREPLACE_DEF,
  },
};

Finally, you should be able to do the following test in in_process:

if(ch == tp->tty_termios.c_cc[VREPLACE])

You will have to figure out where in in_process to place this check. Also, you still have to worry about catching the interger and character parameters required. I suggest using flags. So when you know CTRL-P has been pressed, set a flag to indicate that now you are looking for CTRL-# (where # is some number 1-9). Then set another flag indicating you are looking for a character, etc. You might find other macros defined in keymap.h to be useful.

Part 2

For this part of lab 3, you only have to write a test program. This is because:

  • Minix already releases a zombie’s memory as soon as it exits and enters the zombie state. (See the book on pages 367-368, or look at the source code.)
  • The hotkey F2 already prints out a memory map.

Part 3

It may be easier to add a new system call for this part, versus modifying lseek. You can find a short guide on adding a system call to Minix on last quarter's TA website. The URL is http://wwwcsif.cs.ucdavis.edu/~cs150/syscall.html. (rest pending)