CS519 02                                       Assignment 1
Due on 07/30/2007 

Part I: Group Report of Lecture Notes and Textbook studied on OS Concepts (Ch 1), Deadlocks (Ch 3), and Memory Management (Ch4)

Write a Microsoft report to summarize your group study activities. The report must have the following.

1.     The time and date of your group study and the topics covered in each study session.

2.     The group discussion summary of each topic studied.

3.     Questions and answers and any issues discussed in each study session.

4.     Conclusions of knowledge learned.

Email the report to the instructor on the due day.

Part II: OS Shell Project on cs1

Write a C/C++ program to simulate a simple shell (command interpreter) on CS1 UNIX (Solaris).
The program operations will be used to illustrate the process creation, synchronization, and execution using FORK, WAIT, and EXEC (You may use SYSTEM if you have difficulties in using EXEC) UNIX system calls.
The shell should be called SSH (short for Simple SHell) and its initial prompt should be "> ".

1. SSH should first prompt user for the login name and password. The list of login names and passwords should be stored in a table.
 SSH will continue with a new "ssh> " prompt if the login is successfully.

 - The password stored in the table must be encrypted.
 - You may use any available encryption function or design your own encryption function to encrypt the password.

2. SSH should then read the command and parameters entered by the user,
 where the syntax of commands is:

 command [parameter | [parameter]*]   /* [] means optional, | means or, * means 0 or more */

 SSH will analyze the command. If the command is one of the following commands
 supported by the SSH, it forks a new process to execute the command.
 Otherwise it prints the error message.

The SSH commands should be initially stored in an external file and read into a command array SSH starts.

 The initial set of 7 commands supported by the SSH is:

 changepwd /* Change the password – Write your own SSH function to change the password */
 copy3 fileName1 fileName2 [fileName3]
     /* Copies the contents of fileName1 and fileName2 onto the screen
         or copy fileName1 and fileName2 to fileName3 if fileName3 is provided. You may use the UNIX command to copy the files*/
 editfile [subdirName].fileName
    /* edit an existed file in the current directory or in a subdirectory if the subdirName is provided. You may use the UNIX command to edit the file */
 displayprocess [loginName] /* display the status of all current processes, or display the processes belong to the user
         if the loginName is provided.  You may use the UNIX command to display processes status */
 searchword word fileName
     /* search a word in a file.
         Print the lines where the word is found. You may use the UNIX command to search a word in the file */
 listhistory /* list of all previous commands executed - Write your own SSH function to list the history */
 logoutssh /* the SSH should exit the shell after other commands are completed. */

(Extra credit:  Program the upper arrow key to list the previous command executed.)

3) SSH should fork a child process to execute the command. The parent process will wait for the
 termination of the child process before go back to the "ssh>" prompt if the command is in a foreground process, otherwise it simply go back to the "ssh>" prompt if the command is in a background process.
 - The command should be executed as a background process if a “&” sign is followed with the command.

4) The main() function should follow the program structure outlined in “A Sample Shell Simulator” on the Chapter 1 of the lecture notes. 

Testing Requirements:
 Test every command supported by the SSH in a foreground process. Test one command in a background process.

Assignment Hand-in Policies:
   1) Email me a Microsoft word report that describe your program structure and operations.
       Attach the programs source code and run results (screen shots) on your report.
       Instructor may ask you to demonstrate your program run to the instructor if needed.
   2) Good program modular design, data structures, algorithms, and internal documentation are part of the grade.
   3) Non-working program will have at most 50% of the total grade.