Homework 1

Process Management

In this homework you'll become familiar with the process management services on the Unix operating system. As we learned in class, the key components of the process creation API are:

For more information on the semantics and arguments to these calls, check out their Unix man pages (man 2 ...).

For this assignment, you are to write a simple shell-like command processor. In principle, your processor will act just as the many Unix shells do -- reading in commands from the console, executing the commands, printing their status on completion, and looping to read the next command. Suppose your shell is called "mysh" and uses "*" as a prompt -- then, a typical interaction with "mysh" would look like (comments are indicated by # text):

% ./mysh		# start up mysh
*			# hit CR
* /bin/ls .		# list the contents of the current directory
mysh	mysh.c	mysh.o
* myshstatus
Last command exited with status 0
* /bin/date
Sun Jan 10 19:27:07 PST 1999
* myshstatus
Last command exited with status 0
* /usr/ucb/users
bershad bershad fred john smith
* myshtime
Last command took .2 seconds to execute.
* exit	# exit from mysh; returning to top level shell
%	

There are several things going on here worth noting since you will have to implement accordingly:

  1. from the standard Unix shell, we start up mysh as a regular command.
  2. mysh reads commands, one line at a time and executes them. Carriage return (the null command) causes nothing to execute.
  3. In response to your command, "mysh" synchronously executes the command (note that you may rely on fully qualified path names) with any arguments. There is no explicit job control -- all commands execute to completion. (Contrast this to Unix's job control services).
  4. mysh supports the builtin function myshstatus which prints the status of the most recently executed command. Command status is available via the wait system call.
  5. mysh supports the builtin function myshtime which prints the elapsed time of the most recently executed command. You will need to use the Unix gettimeofday() timekeeping facilities for this.
  6. mysh supports the builtin function exit.

What to turn in:

This assignment is to be done individually.

You must implement the solution in a single C source file called mysh.c.

Please email your single source file to cse451-hw@cs.washington.edu by 11:59 pm on Monday, January 18th. Your email message should have the subject: Homework 1 and the message should include nothing but the source file. We will be autoprocessing your mail message by storing it in a directory, compiling and executing it, so if the mail contains anything but compilable source code, we will not be able to grade your assignment.

When to turn it in:

This assignment is due on Monday, January 18th. It will be worth 10 points and graded with this criteria in mind: