CS 3013 Operating Systems I WPI, A Term 1996
Craig E. Wills Project 1 (15 pts)
Assigned: Thursday, August 29, 1996 Due: Friday, September 6, 1996

Introduction

This assignment is intended to introduce you to the process manipulation facilities in the Unixgif Operating System. You are to implement the program described below on any CCC DEC machines.

Basic Objective

You are to write a program doit that takes another command as an argument and executes that command. For instance, executing:

% doit cat /etc/motd
would invoke the cat command on the file /etc/motd, which will print the current ``message of the day.'' After execution of the specified command has completed, doit should display statistics that show some of system resources the command used. In particular, doit should print:

  1. the amount of CPU time used (both user and system time),

  2. the number of times the process was preempted involuntarily (e.g. time slice expired, preemption by higher priority process),

  3. the number of times the process gave up the CPU voluntarily (e.g. waiting for a resource),

  4. the number of page faults, and

  5. the number of page faults that could be satisfied from the kernel's internal cache (e.g. did not require any input/output operations).

Additional Work

Satisfactory completion of the basic objective of this assignment is worth 13 of the 15 points. For the additional two points, your program should be extended to behave like a shell program if no arguments are given at the command line. Your program should continually prompt for a command (which may have multiple arguments separated by white space) then execute the command and print the statistics. This work will involve breaking the line of text you read into an argument list. Your program should continue to read and execute commands until the command exit is given or the end-of-file is reached. Note: you may not use the system call system available in Unix to execute the entered command. A sample session is given below with comments given in <>.

% doit
==>ls
        < listing of files in the current directory >
        < statistics about this ls command >
==>cat /etc/motd
        < print the current message of the day >
        < statistics about this cat command >
==>exit
%       < back to the Unix prompt >

You should also observe how your mini-shell works in comparison to a regular Unix shell. Does it have all the same features? What limitations does it have? You should include your observations as a comment in your code that is turned in.

Helpful Hints

The following system calls might be useful:

To get help information about these routines, use the Unix ``man'' command. For instance, entering ``man fork'' will display the manual page entry for fork on the terminal. The manual pages are organized into sections. Section 1 is for Unix commands, section 2 is for Unix system calls and section 3 is for Unix library routines. Some entries are contained in more than one section. For example to obtain information about the system call wait() (rather than the command wait) use ``man 2 wait'' where the section is explicitly given.

Submission of Assignment

Submit your assignment for grading as directed in class.