CSC 442

Homework 1

Write a program which exhibits the following behavior (assume that the program is run as process P1):

  1. Prints the message "P1: I am going to create a new process".
  2. Creates a new process P2
  3. The newly created process P2 prints the message: "P2: I am the new process".
  4. P1 prints the message "P1: I have created a new process".



NB: The words in bold are what you see on the screen. The rest is what you have to type in. I suggest you write the program in C or C++. However, Pascal is also acceptable if this is the language that you have been taught in CSC110, CSC220.

  1. Write your program on a piece of paper. Do not continue with step 2 until you are sure the program will work.

  3. Log in on Unix using your user name and password.
  4. SunOS UNIX (

    login: your_username

    Password: your_password

    Last login: Mon Sep 29 16:43:37 from perseus.cs.wayne

    SunOS Release 4.1.3C (FS2) #1: Fri Apr 18 11:22:33 EDT 1997

    jupiter[1] %


  5. Change your password (if you have not already done so) using the command passwd. Do not forget your password.
  6. jupiter[1] %passwd

    Enter your old password:

    Enter your new password:

    Re-enter your new password:


  7. Edit your program using a text editor like vi, emacs, edit, etc. Create a text file with the name process.c

  9. Compile your program using the command gcc.
  10. jupiter[1] %gcc -o process process.c


  11. Run your program.
  12. jupiter[1] %process


  13. If you spot errors or the program does not behave as desired, go back to 4, edit your file correcting the errors, re-compile and run it again until it works. When it works, change the permissions on the source and executable file so that I can access the file. Do that with the command:

jupiter[1] %chmod 707 *




  1. A print-out of your program.
  2. A written description of the program and its behavior.